Module:SemanticAnnotations: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- | --[[ | ||
* Name: SemanticAnnotations | |||
* Author: Mark W. Datysgeld | |||
* Description: Primary semantic integration module for generating semantic properties with transformation support and property limits | |||
* Notes: Implements batching, deduplication and property limits (200 total, 25 per property); supports simple, object, complex, and subobject mappings; falls back to parser functions when mw.smw unavailable; includes pruning to prevent server crashes | |||
]] | |||
local p = {} | local p = {} | ||
| Line 10: | Line 14: | ||
local VALUE_LIMIT = 25 -- per individual property | local VALUE_LIMIT = 25 -- per individual property | ||
--[[ Fallback for mw.smw.set using the #set parser function. | |||
--[[ | |||
@param args - Template parameters | @param args - Template parameters | ||
@param mappings - Property mappings: {["Property"] = "param"} or complex format | @param mappings - Property mappings: {["Property"] = "param"} or complex format | ||
| Line 82: | Line 80: | ||
-- Return result or empty string | -- Return result or empty string | ||
return propertyCount > 0 and table.concat(result, "\n") or "" | return propertyCount > 0 and table.concat(result, "\n") or "" | ||
end | end | ||
| Line 206: | Line 174: | ||
end | end | ||
-- Enhanced | -- Enhanced fallback for mw.smw.set with complex mapping support. | ||
function p.generateEnhancedAnnotations(args, mappings, options) | function p.generateEnhancedAnnotations(args, mappings, options) | ||
args = args or {} | args = args or {} | ||
| Line 289: | Line 257: | ||
end | end | ||
--[[ Sets semantic properties | --[[ Sets semantic properties using the native mw.smw API. | ||
This is the primary function for setting semantic data. | |||
@param args - Template parameters | @param args - Template parameters | ||
@param mappings - Property mappings in formats: | @param mappings - Property mappings in formats: | ||