Module:LuaTemplateBlueprint: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 964: Line 964:
     }
     }
      
      
     -- Create collector with early deduplication
    -- 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 basic properties with early deduplication
    for property, param in pairs(properties) do
        if not skipProperties[property] then
            -- Perform case-insensitive lookup for the parameter key
            local keyName, value = TemplateHelpers.getFieldValue(args, { key = param })
            if value and value ~= '' then
                -- Apply transform if needed
                if transforms[property] then
                    value = applyTransform(value, property, transforms[property], args, template)
                end
                deduplicateProperty(collector, property, value)
            end
        end
    end
      
      
     -- 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: total_props=%d, unique_signatures=%d -->",
         "<!-- 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 deduplicated properties to SemanticAnnotations in one batch
     -- Send all properties to SemanticAnnotations in one batch
     local semanticOutput = SemanticAnnotations.setSemanticProperties(
     local semanticOutput = SemanticAnnotations.setSemanticProperties(
         args,
         args,
         collector.properties,
         finalProperties,
         semanticOptions
         semanticOptions
     )
     )