Module:LuaTemplateBlueprint: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 964: | Line 964: | ||
} | } | ||
-- Create collector | -- Build initial property mapping (like original code) | ||
local allProperties = {} | |||
-- Process basic properties - just map property names to field names | |||
for property, param in pairs(properties) do | |||
if not skipProperties[property] then | |||
-- Just map the property to the field name | |||
-- SemanticAnnotations will handle value extraction and transforms | |||
allProperties[property] = param | |||
end | |||
end | |||
-- Create collector for deduplication of additional properties and providers | |||
local collector = { | local collector = { | ||
seen = {}, -- Track property:value signatures | seen = {}, -- Track property:value signatures | ||
| Line 970: | Line 982: | ||
count = 0 -- Track total property count | count = 0 -- Track total property count | ||
} | } | ||
-- Process additional properties with early deduplication and multi-value handling | -- Process additional properties with early deduplication and multi-value handling | ||
| Line 1,110: | Line 1,107: | ||
end | end | ||
end | end | ||
end | |||
-- Merge basic properties mapping with deduplicated additional properties | |||
-- Basic properties (allProperties) contains field mappings | |||
-- Additional properties (collector.properties) contains actual values | |||
local finalProperties = {} | |||
-- Copy basic property mappings | |||
for property, fieldName in pairs(allProperties) do | |||
finalProperties[property] = fieldName | |||
end | |||
-- Add deduplicated additional properties (these have actual values) | |||
for property, value in pairs(collector.properties) do | |||
finalProperties[property] = value | |||
end | end | ||
-- Add debug info as HTML comment (Phase 1 monitoring) | -- Add debug info as HTML comment (Phase 1 monitoring) | ||
local basicCount = 0 | |||
for _ in pairs(allProperties) do basicCount = basicCount + 1 end | |||
local debugInfo = string.format( | local debugInfo = string.format( | ||
"<!-- SMW Debug: | "<!-- SMW Debug: basic_props=%d, additional_props=%d, unique_signatures=%d -->", | ||
basicCount, | |||
collector.count or 0, | collector.count or 0, | ||
table.maxn(collector.seen or {}) | table.maxn(collector.seen or {}) | ||
) | ) | ||
-- Send all | -- Send all properties to SemanticAnnotations in one batch | ||
local semanticOutput = SemanticAnnotations.setSemanticProperties( | local semanticOutput = SemanticAnnotations.setSemanticProperties( | ||
args, | args, | ||
finalProperties, | |||
semanticOptions | semanticOptions | ||
) | ) | ||