Wiktionary siwiktionary https://si.wiktionary.org/wiki/%E0%B7%80%E0%B7%92%E0%B6%9A%E0%B7%8A%E0%B7%82%E0%B6%B1%E0%B6%BB%E0%B7%92:%E0%B6%B8%E0%B7%94%E0%B6%BD%E0%B7%8A_%E0%B6%B4%E0%B7%92%E0%B6%A7%E0%B7%94%E0%B7%80 MediaWiki 1.48.0-wmf.4 case-sensitive මාධ්‍යය විශේෂ සාකච්ඡාව පරිශීලක පරිශීලක සාකච්ඡාව වික්ෂනරි වික්ෂනරි සාකච්ඡාව ගොනුව ගොනුව සාකච්ඡාව මාධ්‍යවිකි මාධ්‍යවිකි සාකච්ඡාව සැකිල්ල සැකිලි සාකච්ඡාව උදවු උදවු සාකච්ඡාව ප්‍රවර්ගය ප්‍රවර්ග සාකච්ඡාව TimedText TimedText talk Module Module talk Event Event talk Module:form of 828 5227 238977 221679 2026-09-17T06:13:30Z en>Benwing2 0 show_qualifiers -> show_decorations 238977 Scribunto text/plain local export = {} export.force_cat = false -- for testing; set to true to display categories even on non-mainspace pages local debug_track_module = "Module:debug/track" local etymology_module = "Module:etymology" local form_of_cats_module = "Module:form of/cats" local form_of_data_module = "Module:form of/data" local form_of_data1_module = "Module:form of/data/1" local form_of_data2_module = "Module:form of/data/2" local form_of_functions_module = "Module:form of/functions" local form_of_lang_data_module_prefix = "Module:form of/lang-data/" local function_module = "Module:fun" local headword_data_module = "Module:headword/data" local json_module = "Module:JSON" local labels_module = "Module:labels" local links_module = "Module:links" local load_module = "Module:load" local parse_utilities_module = "Module:parse utilities" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local table_deep_equals_module = "Module:table/deepEquals" local utilities_module = "Module:utilities" local anchor_encode = mw.uri.anchorEncode local concat = table.concat local dump = mw.dumpObject local fetch_categories_and_labels -- Defined below. local format_form_of -- Defined below. local get_tag_display_form -- Defined below. local get_tag_set_display_form -- Defined below. local insert = table.insert local ipairs = ipairs local is_link_or_html -- Defined below. local list_to_text = mw.text.listToText local lookup_shortcut -- Defined below. local lookup_tag -- Defined below. local normalize_tag_set -- Defined below. local parse_tag_set_properties -- Defined below. local require = require local sort = table.sort local split_tag_set -- Defined below. local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function append(...) append = require(table_module).append return append(...) end local function contains(...) contains = require(table_module).contains return contains(...) end local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) end local function deep_equals(...) deep_equals = require(table_deep_equals_module) return deep_equals(...) end local function extend(...) extend = require(table_module).extend return extend(...) end local function format_categories(...) format_categories = require(utilities_module).format_categories return format_categories(...) end local function full_link(...) full_link = require(links_module).full_link return full_link(...) end local function insert_if_not(...) insert_if_not = require(table_module).insertIfNot return insert_if_not(...) end local function is_subset_list(...) is_subset_list = require(table_module).isSubsetList return is_subset_list(...) end local function iterate_from(...) iterate_from = require(function_module).iterateFrom return iterate_from(...) end local function join_multiparts(...) join_multiparts = require(form_of_functions_module).join_multiparts return join_multiparts(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function parse_inline_modifiers(...) parse_inline_modifiers = require(parse_utilities_module).parse_inline_modifiers return parse_inline_modifiers(...) end local function remove_links(...) remove_links = require(links_module).remove_links return remove_links(...) end local function safe_load_data(...) safe_load_data = require(load_module).safe_load_data return safe_load_data(...) end local function safe_require(...) safe_require = require(load_module).safe_require return safe_require(...) end local function serial_comma_join(...) serial_comma_join = require(table_module).serialCommaJoin return serial_comma_join(...) end local function shallow_copy(...) shallow_copy = require(table_module).shallowCopy return shallow_copy(...) end local function show_labels(...) show_labels = require(labels_module).show_labels return show_labels(...) end local function slice(...) slice = require(table_module).slice return slice(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function ucfirst(...) ucfirst = require(string_utilities_module).ucfirst return ucfirst(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local cat_functions local function get_cat_functions() cat_functions, get_cat_functions = require(form_of_functions_module).cat_functions, nil return cat_functions end local default_pagename local function get_default_pagename() default_pagename, get_default_pagename = load_data(headword_data_module).pagename, nil return default_pagename end local display_handlers local function get_display_handlers() display_handlers, get_display_handlers = require(form_of_functions_module).display_handlers, nil return display_handlers end local m_cats_data local function get_m_cats_data() m_cats_data, get_m_cats_data = load_data(form_of_cats_module), nil return m_cats_data end local m_data local function get_m_data() -- Needs require. m_data, get_m_data = require(form_of_data_module), nil return m_data end local m_data1 local function get_m_data1() m_data1, get_m_data1 = load_data(form_of_data1_module), nil return m_data1 end local m_data2 local function get_m_data2() m_data2, get_m_data2 = load_data(form_of_data2_module), nil return m_data2 end local m_pos_data local function get_m_pos_data() m_pos_data, get_m_pos_data = load_data(headword_data_module).pos_aliases, nil return m_pos_data end --[==[ intro: This module implements the underlying processing of {{tl|form of}}, {{tl|inflection of}} and specific variants such as {{tl|past participle of}} and {{tl|alternative spelling of}}. Most of the logic in this file is to handle tags in {{tl|inflection of}}. Other related files: * [[Module:form of/templates]] contains the majority of the logic that implements the templates themselves. * [[Module:form of/data/1]] is a data-only file containing information on the more common inflection tags, listing the tags, their shortcuts, the category they belong to (tense-aspect, case, gender, voice-valence, etc.), the appropriate glossary link and the wikidata ID. * [[Module:form of/data/2]] is a data-only file containing information on the less common inflection tags, in the same format as [[Module:form of/data/1]]. * [[Module:form of/lang-data/LANGCODE]] is a data-only file containing information on the language-specific inflection tags for the language with code LANGCODE, in the same format as [[Module:form of/data/1]]. Language-specific tags override general tags. * [[Module:form of/cats]] is a data-only file listing the language-specific categories that are added when the appropriate combinations of tags are seen for a given language. * [[Module:form of/functions]] contains functions for use with [[Module:form of/data/1]] and [[Module:form of/cats]]. They are contained in this module because data-only modules can't contain code. The functions in this file are of two types: *# Display handlers allow for customization of the display of multipart tags (see below). Currently there is only one such handler, for handling multipart person tags such as `1//2//3`. *# Cat functions allow for more complex categorization logic, and are referred to by name in [[Module:form of/cats]]. Currently no such functions exist. The following terminology is used in conjunction with {{tl|inflection of}}: * A ''tag'' is a single grammatical item, as specified in a single numbered parameter of {{tl|inflection of}}. Examples are `masculine`, `nominative`, or `first-person`. Tags may be abbreviated, e.g. `m` for `masculine`, `nom` for `nominative`, or `1` for `first-person`. Such abbreviations are called ''aliases'', and some tags have multiple equivalent aliases (e.g. `p` or `pl` for `plural`). The full, non-abbreviated form of a tag is called its ''canonical form''. * The ''display form'' of a tag is the way it's displayed to the user. Usually the displayed text of the tag is the same as its canonical form, and it normally functions as a link to a glossary entry explaining the tag. Usually the link is to an entry in [[Appendix:Glossary]], but sometimes the tag is linked to an individual dictionary entry or to a Wikipedia entry. Occasionally, the display text differs from the canonical form of the tag. An example is the tag `comparative case`, which has the display text read as simply `comparative`. Normally, tags referring to cases don't have the word "case" in them, but in this case the tag `comparative` was already used as an alias for the tag `comparative degree`, so the tag was named `comparative case` to avoid clashing. A similar situation occurs with `adverbial case` vs. the grammar tag `adverbial` (as in `adverbial participle`). * A ''tag set'' is an ordered list of tags, which together express a single inflection, for example, `1|s|pres|ind`, which can be expanded to canonical-form tags as `first-person|singular|present|indicative`. * A ''conjoined tag set'' is a tag set that consists of multiple individual tag sets separated by a semicolon, e.g. `1|s|pres|ind|;|2|s|imp`, which specifies two tag sets, `1|s|pres|ind` as above and `2|s|imp` (in canonical form, `second-person|singular|imperative`). Multiple tag sets specified in a single call to {{tl|inflection of}} are specified in this fashion. Conjoined tag sets can also occur in list-tag shortcuts. * A ''multipart tag'' is a tag that embeds multiple tags within it, such as `f//n` or `nom//acc//voc`. These are used in the case of [[syncretism]], when the same form applies to multiple inflections. Examples are the Spanish present subjunctive, where the first-person and third-person singular have the same form (e.g. {{m|es|siga}} from {{m|es|seguir|t=to follow}}), or Latin third-declension adjectives, where the dative and ablative plural of all genders have the same form (e.g. {{m|la|omnibus}} from {{m|la|omnis|t=all}}). These would be expressed respectively as `1//3|s|pres|sub` and `dat//abl|m//f//n|p`, where the use of the multipart tag compactly encodes the syncretism and avoids the need to individually list out all of the inflections. Multipart tags currently display as a list separated by a slash, e.g. ''dative/ablative'' or ''masculine/feminine/neuter'' where each individual word is linked appropriately. As a special case, multipart tags involving persons display specially; for example, the multipart tag `1//2//3` displays as ''first-, second- and third-person'', with the word "person" occurring only once. * A ''two-level multipart tag'' is a special type of multipart tag that joins two or more tag sets instead of joining individual tags. The tags within the tag set are joined by a colon, e.g. `1:s//3:p`, which is displayed as ''first-person singular and third-person plural'', e.g. for use with the form {{m|grc|μέλλον}} of the verb {{m|grc|μέλλω|t=to intend}}, which uses the tag set `1:s//3:p|impf|actv|indc|unaugmented` to express the syncretism between the first singular and third plural forms of the imperfect active indicative unaugmented conjugation. Two-level multipart tags should be used sparingly; if in doubt, list out the inflections separately. [FIXME: Make two-level multipart tags obsolete.] * A ''shortcut'' is a tag that expands to any type of tag described above, or to any type of tag set described above. Aliases are a particular type of shortcut whose expansion is a single non-multipart tag. * A ''multipart shortcut'' is a shortcut that expands into a multipart tag, for example `123`, which expands to the multipart tag `1//2//3`. Only the most common such combinations exist as shortcuts. * A ''list shortcut'' is a special type of shortcut that expands to a list of tags instead of a single tag. For example, the shortcut `1s` expands to `1|s` (first-person singular). Only the most common such combinations exist as shortcuts. * A ''conjoined shortcut'' is a special type of list shortcut that consists of a conjoined tag set (multiple logical tag sets). For example, the English language-specific shortcut `ed-form` expands to `spast|;|past|part`, expressing the common syncretism between simple past and past participle in English (and in this case, `spast` is itself a list shortcut that expands to `simple|past`).]==] -- Add tracking category for PAGE when called from {{inflection of}} or -- similar TEMPLATE. The tracking category linked to is -- [[Wiktionary:Tracking/inflection of/PAGE]]. local function track(page) debug_track("inflection of/" .. -- avoid including links in pages (may cause error) page:gsub("%[", "("):gsub("%]", ")"):gsub("|", "!") ) end local function wrap_in_span(text, classes) if classes then return ("<span class='%s'>%s</span>"):format(classes, text) else return text end end local function show_linked_term(data) local termobj, face, span_classes, ok_to_destructively_modify, overall_lang, text_classes = data.termobj, data.face, data.span_classes, data.ok_to_destructively_modify, data.overall_lang, data.text_classes local need_to_copy, pretext_lang local categories = {} if overall_lang and overall_lang:getCode() ~= termobj.lang:getCode() then local lang_display lang_display, categories = require(etymology_module).insert_source_cat_get_display { lang = data.overall_lang, source = termobj.lang, } pretext_lang = wrap_in_span(lang_display .. " ", text_classes) end local has_decoration = termobj.q or termobj.qq or termobj.a or termobj.aa or termobj.l or termobj.ll or termobj.refs -- `show_decorations` is set by parse_{term,list}_with_inline_modifiers_and_separate_params in -- [[Module:parameter utilities]], called in [[Module:form of/templates]], so in most circumstances -- it's already set and we don't need to do a shallow-copy to set it. local need_to_set_show_decorations = has_decoration and not termobj.show_decorations need_to_copy = not ok_to_destructively_modify and (pretext_lang or need_to_set_show_decorations) if need_to_copy then termobj = shallow_copy(termobj) end if pretext_lang then termobj.pretext = pretext_lang end if need_to_set_show_decorations then termobj.show_decorations = true end return wrap_in_span(full_link(termobj, face), span_classes), categories end --[==[ Lowest-level implementation of form-of templates, including the general {{tl|form of}} as well as those that deal with inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with the following fields: * `.lang`: Overall language of the form-of template. If specified, any lemmas, enclitics or base lemmas that are of a different language will have that language displayed before the term in question. * `.text`: Text to insert before the lemmas. Wrapped in the value of `.text_classes`, or its default; see below. * `.lemmas`: List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly, or omitted, to show no lemma links and omit the connecting text. * `.lemma_face`: "Face" to use when displaying the lemma objects. Usually should be set to {"term"}. * `.conj`: Conjunction or separator to use when joining multiple lemma objects. If {nil}, defaults to {"and"}. If this has the value {false}, the lemmas are preceded with the `.separator` field in each lemma. * `.enclitics`: List of enclitics to display after the lemmas, in parens. * `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}. * `.base_lemmas`: List of base lemmas to display after the lemmas, in the case where the lemmas in `.lemmas` are themselves forms of another lemma (the base lemma), e.g. a comparative, superlative or participle. Each object is of the form { { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, conj = "CONJ" }} where PARAM_OBJ describes the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas); LEMMA_OBJ is an object suitable to be passed to {full_link()} in [[Module:links]]; and CONJ is the conjunction to join multiple lemmas with, defaulting to {"and"}. PARAM_OBJ is of the format { { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{tl|inflection of}} etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as { {"comd"}} or { {"past", "part"}}. * `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is {"form-of-definition use-with-mention"}. Use `false` for no wrapping. * `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}. Use `false` for no wrapping. * `.posttext`: Additional text to display after the lemma links. * `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified in-place to save memory; otherwise they will be copied before modifying. Returns two values, the formatted string and any categories to add the page to (which will arise if `.lang` is specified and a language other than `.lang` is given in one of the lemmas in `.lemmas` or enclitics in `.enclitics`). ]==] function export.format_form_of(data) if type(data) ~= "table" then error("Internal error: First argument must now be a table of arguments") end local text_classes = data.text_classes if text_classes == nil and not data.nowrap then text_classes = "form-of-definition use-with-mention" end local lemma_classes = data.lemma_classes if lemma_classes == nil then lemma_classes = "form-of-definition-link" end local parts = {} if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end insert(parts, data.text) if data.text ~= "" and data.lemmas then insert(parts, " ") end local categories = {} if data.lemmas then if type(data.lemmas) == "string" then insert(parts, wrap_in_span(data.lemmas, lemma_classes)) else local formatted_terms = {} for _, lemma in ipairs(data.lemmas) do local linked_term, this_categories = show_linked_term { termobj = lemma, face = data.lemma_face, span_classes = lemma_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, overall_lang = data.lang, text_classes = text_classes } if this_categories[1] then extend(categories, this_categories) end if data.conj == false and lemma.separator then insert(formatted_terms, lemma.separator) end insert(formatted_terms, linked_term) end if data.conj == false then insert(parts, concat(formatted_terms)) else insert(parts, serial_comma_join(formatted_terms, {conj = data.conj or "and"})) end end if data.lit then insert(parts, ", literally " .. require(links_module).mark(data.lit, "gloss")) end end if data.enclitics and #data.enclitics > 0 then -- The outer parens need to be outside of the text_classes span so they show in upright instead of italic, or -- they will clash with upright parens generated by link annotations such as transliterations and pos=. if text_classes then insert(parts, "</span>") end local formatted_terms = {} for _, enclitic in ipairs(data.enclitics) do -- FIXME, should we have separate clitic face and/or classes? local linked_term, this_categories = show_linked_term { termobj = enclitic, face = data.lemma_face, span_classes = lemma_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, overall_lang = data.lang, text_classes = text_classes } if this_categories[1] then extend(categories, this_categories) end insert(formatted_terms, linked_term) end insert(parts, " (") insert(parts, wrap_in_span("with enclitic" .. (#data.enclitics > 1 and "s" or "") .. " ", text_classes)) insert(parts, serial_comma_join(formatted_terms, {conj = data.enclitic_conj or "and"})) insert(parts, ")") if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end end if data.base_lemmas and #data.base_lemmas > 0 then for _, base_lemma in ipairs(data.base_lemmas) do insert(parts, ", the ") if text_classes then insert(parts, "</span>") end insert(parts, (export.tagged_inflections { lang = data.lang or base_lemma.lemmas[1].lang, tags = base_lemma.paramobj.tags, lemmas = base_lemma.lemmas, conj = base_lemma.conj or "and", lemma_face = data.lemma_face, no_format_categories = true, nocat = true, text_classes = data.text_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, })) if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end end end -- FIXME, should posttext go before enclitics? If so we need to have separate handling for the -- final colon when there are multiple tag sets in tagged_inflections(). if data.posttext then insert(parts, data.posttext) end if text_classes then insert(parts, "</span>") end return concat(parts), categories end format_form_of = export.format_form_of --[==[ Return true if `tag` contains an internal link or HTML.]==] function export.is_link_or_html(tag) return tag:find("[[", nil, true) or tag:find("|", nil, true) or tag:find("<", nil, true) end is_link_or_html = export.is_link_or_html --[==[ Look up a tag (either a shortcut of any sort of a canonical long-form tag) and return its expansion. The expansion will be a string unless the shortcut is a list-tag shortcut such as `1s`; in that case, the expansion will be a list. The caller must handle both cases. Only one level of expansion happens; hence, `acc` expands to {"accusative"}, `1s` expands to { {"1", "s"}} (not to { {"first", "singular"}}) and `123` expands to {"1//2//3"}. The expansion will be the same as the passed-in tag in the following circumstances: # The tag is `;` (this is special-cased, and no lookup is done). # The tag is a multipart tag such as `nom//acc` (this is special-cased, and no lookup is done). # The tag contains a raw link (this is special-cased, and no lookup is done). # The tag contains HTML (this is special-cased, and no lookup is done). # The tag is already a canonical long-form tag. # The tag is unrecognized. This function first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in [[Module:form of/data/1]] (which includes more common non-lang-specific tags) and finally (only if the tag is not recognized as a shortcut or canonical tag, and is not of types 1-4 above) in [[Module:form of/data/2]]. If the expansion is a string and is different from the tag, track it if `do_track` is true.]==] function export.lookup_shortcut(tag, lang, do_track) -- If there is HTML or a link in the tag, return it directly; don't try -- to look it up, which will fail. if tag == ";" or tag:find("//", nil, true) or is_link_or_html(tag) then return tag end local expansion while lang do local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode()) -- If this is a canonical long-form tag, just return it, and don't check for shortcuts. This is an -- optimization; see below. if langdata then if langdata.tags[tag] then return tag end expansion = langdata.shortcuts[tag] if expansion then break end end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end if not expansion then -- If this is a canonical long-form tag, just return it, and don't check for shortcuts (which will cause -- [[Module:form of/data/2]] to be loaded, because there won't be a shortcut entry in [[Module:form of/data/1]] -- -- or, for that matter, in [[Module:form of/data/2]]). This is an optimization; the code will still work without -- it, but will use up more memory. if (m_data1 or get_m_data1()).tags[tag] then return tag end expansion = m_data1.shortcuts[tag] end if not expansion then expansion = (m_data2 or get_m_data2()).shortcuts[tag] end if not expansion then return tag end -- Maybe track the expansion if it's not the same as the raw tag. if do_track and expansion ~= tag and type(expansion) == "string" then track("tag/" .. tag) end return expansion end lookup_shortcut = export.lookup_shortcut --[==[ Look up a normalized/canonicalized tag and return the data object associated with it. If the tag isn't found, return nil. This first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in [[Module:form of/data/1]] (which includes more common non-lang-specific tags) and then finally in [[Module:form of/data/2]].]==] function export.lookup_tag(tag, lang) while lang do local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode()) local tag = langdata and langdata.tags[tag] if tag then return tag end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end local tagobj = (m_data1 or get_m_data1()).tags[tag] if tagobj then return tagobj end local tagobj2 = (m_data2 or get_m_data2()).tags[tag] if tagobj2 then return tagobj2 end return nil end lookup_tag = export.lookup_tag -- Normalize a single tag, which may be a shortcut but should not be a multipart tag, a multipart shortcut or a list -- shortcut. local function normalize_single_tag(tag, lang, do_track) local expansion = lookup_shortcut(tag, lang, do_track) if type(expansion) ~= "string" then error("Tag '" .. tag .. "' is a list shortcut, which is not allowed here") end tag = expansion if not lookup_tag(tag, lang) and do_track then -- If after all expansions and normalizations we don't recognize the canonical tag, track it. track("unknown") track("unknown/" .. tag) end return tag end --[=[ Normalize a component of a multipart tag. This should not have any // in it, but may join multiple individual tags with a colon, and may be a single list-tag shortcut, which is treated as if colon-separated. The return value may be a list of tags. ]=] local function normalize_multipart_component(tag, lang, do_track) -- If there is HTML or a link in the tag, don't try to split on colon. A colon may legitimately occur in either one, -- and we don't want these things parsed. Note that we don't do this check before splitting on //, which we don't -- expect to occur in links or HTML; see comment in normalize_tag(). if is_link_or_html(tag) then return tag end local components = split(tag, ":", true) if #components == 1 then -- We allow list-tag shortcuts inside of multipart tags, e.g. -- '1s//3p'. Check for this now. tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then -- Temporary tracking as we will disallow this. track("list-tag-inside-of-multipart") -- We found a list-tag shortcut; treat as if colon-separated. components = tag else return normalize_single_tag(tag, lang, do_track) end end local normtags = {} -- Temporary tracking as we will disallow this. track("two-level-multipart") for _, component in ipairs(components) do if do_track then -- There are multiple components; track each of the individual -- raw tags. track("tag/" .. component) end insert(normtags, normalize_single_tag(component, lang, do_track)) end return normtags end --[=[ Normalize a single tag. The return value may be a list (in the case of multipart tags), which will contain nested lists in the case of two-level multipart tags. ]=] local function normalize_tag(tag, lang, do_track) -- We don't check for links or HTML before splitting on //, which we don't expect to occur in links or HTML. Doing -- it this way allows for a tag like '{{lb|grc|Epic}}//{{lb|grc|Ionic}}' to function correctly (the template calls -- will be expanded before we process the tag, and will contain links and HTML). The only check we do is for a URL, -- which shouldn't normally occur, but might if the user tries to put an external link into the tag. URL's with // -- normally have the sequence ://, which should never normally occur when // and : are used in their normal ways. if tag:find("://", nil, true) then return tag end local split_tags = split(tag, "//", true) if #split_tags == 1 then local retval = normalize_multipart_component(tag, lang, do_track) if type(retval) == "table" then -- The user gave a tag like '1:s', i.e. with colon but without //. Allow this, but we need to return a -- nested list. return {retval} end return retval end local normtags = {} for _, single_tag in ipairs(split_tags) do if do_track then -- If the tag was a multipart tag, track each of individual raw tags. track("tag/" .. single_tag) end insert(normtags, normalize_multipart_component(single_tag, lang, do_track)) end return normtags end --[==[ Normalize a tag set (a list of tags) into its canonical-form tags. The return value is a list of normalized tag sets (a list because of there may be conjoined shortcuts among the input tags). A normalized tag set is a list of tag elements, where each element is either a string (the canonical form of a tag), a list of such strings (in the case of multipart tags) or a list of lists of such strings (in the case of two-level multipart tags). For example, the multipart tag `nom//acc//voc` will be represented in canonical form as { {"nominative", "accusative", "vocative"}}, and the two-level multipart tag `1:s//3:p` will be represented as { {{"first-person", "singular"}, {"third-person", "plural"}}}. Example 1: {normalize_tag_set({"nom//acc//voc", "n", "p"})} = { {{{"nominative", "accusative", "vocative"}, "masculine", "plural"}}} Example 2: {normalize_tag_set({"ed-form"}, ENGLISH)} = { {{"simple", "past"}, {"past", "participle"}}} Example 3: {normalize_tag_set({"archaic", "ed-form"}, ENGLISH)} = { {{"archaic", "simple", "past"}, {"archaic", "past", "participle"}}}]==] function export.normalize_tag_set(tag_set, lang, do_track) -- We track usage of shortcuts, normalized forms and (in the case of multipart tags or list tags) intermediate -- forms. For example, if the tags 1s|mn|gen|indefinite are passed in, we track the following: -- [[Wiktionary:Tracking/inflection of/tag/1s]] -- [[Wiktionary:Tracking/inflection of/tag/1]] -- [[Wiktionary:Tracking/inflection of/tag/s]] -- [[Wiktionary:Tracking/inflection of/tag/first-person]] -- [[Wiktionary:Tracking/inflection of/tag/singular]] -- [[Wiktionary:Tracking/inflection of/tag/mn]] -- [[Wiktionary:Tracking/inflection of/tag/m//n]] -- [[Wiktionary:Tracking/inflection of/tag/m]] -- [[Wiktionary:Tracking/inflection of/tag/n]] -- [[Wiktionary:Tracking/inflection of/tag/masculine]] -- [[Wiktionary:Tracking/inflection of/tag/neuter]] -- [[Wiktionary:Tracking/inflection of/tag/gen]] -- [[Wiktionary:Tracking/inflection of/tag/genitive]] -- [[Wiktionary:Tracking/inflection of/tag/indefinite]] local output_tag_set = {} local saw_semicolon = false for _, tag in ipairs(tag_set) do if do_track then -- Track the raw tag. track("tag/" .. tag) end -- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list -- of tags). tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then if contains(tag, ";") then -- If we saw a conjoined shortcut, we need to use a more general algorithm that can expand a single -- tag set into multiple. saw_semicolon = true break end for _, t in ipairs(tag) do if do_track then -- If the tag expands to a list of raw tags, track each of those. track("tag/" .. t) end insert(output_tag_set, normalize_tag(t, lang, do_track)) end else insert(output_tag_set, normalize_tag(tag, lang, do_track)) end end if not saw_semicolon then return {output_tag_set} end -- Use a more general algorithm that handles conjoined shortcuts. output_tag_set = {} for i, tag in ipairs(tag_set) do if do_track then -- Track the raw tag. track("tag/" .. tag) end -- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list -- of tags). tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then local output_tag_sets = {} local shortcut_tag_sets = split_tag_set(tag) local normalized_shortcut_tag_sets = {} for _, shortcut_tag_set in ipairs(shortcut_tag_sets) do extend(normalized_shortcut_tag_sets, normalize_tag_set(shortcut_tag_set, lang, do_track)) end local after_tags = slice(tag_set, i + 1) local normalized_after_tags_sets = normalize_tag_set(after_tags, lang, do_track) for _, normalized_shortcut_tag_set in ipairs(normalized_shortcut_tag_sets) do for _, normalized_after_tags_set in ipairs(normalized_after_tags_sets) do insert(output_tag_sets, append(output_tag_set, normalized_shortcut_tag_set, normalized_after_tags_set)) end end return output_tag_sets else insert(output_tag_set, normalize_tag(tag, lang, do_track)) end end error("Internal error: Should not get here") end normalize_tag_set = export.normalize_tag_set --[==[ Split a tag set that may consist of multiple semicolon-separated tag sets into the component tag sets.]==] function export.split_tag_set(tag_set) local split_tag_sets = {} local cur_tag_set = {} for _, tag in ipairs(tag_set) do if tag == ";" then if #cur_tag_set > 0 then insert(split_tag_sets, cur_tag_set) end cur_tag_set = {} else insert(cur_tag_set, tag) end end if #cur_tag_set > 0 then insert(split_tag_sets, cur_tag_set) end return split_tag_sets end split_tag_set = export.split_tag_set local tag_set_param_mods = { lb = { item_dest = "labels", convert = function(arg, _parse_err) return split(arg, "//", true) end, } } --[==[ Parse tag set properties from a tag set (list of tags). Currently no per-tag properties are recognized, and the only per-tag-set property recognized is `<lb:...>` for specifing label(s) for the tag set. Per-tag-set properties must be attached to the last tag.]==] function export.parse_tag_set_properties(tag_set) local function generate_tag_set_obj(last_tag) tag_set[#tag_set] = last_tag return {tags = tag_set} end local last_tag = tag_set[#tag_set] -- Check for inline modifier, e.g. מרים<tr:Miryem>. But exclude HTML entry with <span ...>, <i ...>, <br/> or -- similar in it, caused by wrapping an argument in {{l|...}}, {{af|...}} or similar. Basically, all tags of -- the sort we parse here should consist of a less-than sign, plus letters, plus a colon, e.g. <lb:...>, so if -- we see a tag on the outer level that isn't in this format, we don't try to parse it. The restriction to the -- outer level is to allow generated HTML inside of e.g. qualifier tags, such as foo<q:similar to {{m|fr|bar}}>. if last_tag:find("<", nil, true) and not last_tag:find("^[^<]*<%l*[^%l:]") then return parse_inline_modifiers(last_tag, { param_mods = tag_set_param_mods, generate_obj = generate_tag_set_obj, }) else return generate_tag_set_obj(last_tag) end end parse_tag_set_properties = export.parse_tag_set_properties local function normalize_pos(pos) if not pos then return nil end return (m_pos_data or get_m_pos_data())[pos] or pos end -- Return the display form of a single canonical-form tag. The value -- passed in must be a string (i.e. it cannot be a list describing a -- multipart tag). To handle multipart tags, use get_tag_display_form(). -- A truthy `nolink` suppresses linking. local function get_single_tag_display_form(normtag, lang, nolink) local data = lookup_tag(normtag, lang) local display = normtag -- If the tag has a special display form, use it if data and data.display then display = data.display if nolink then display = remove_links(display) end end -- If there is a nonempty glossary index, then show a link to it if not nolink then local glossary = data and data[(m_data or get_m_data()).GLOSSARY] if glossary ~= nil then if glossary == m_data.WIKT then display = "[[" .. normtag .. "|" .. display .. "]]" elseif glossary == m_data.WP then display = "[[w:" .. normtag .. "|" .. display .. "]]" elseif glossary == m_data.APPENDIX then display = "[[Appendix:Glossary#" .. anchor_encode(normtag) .. "|" .. display .. "]]" elseif type(glossary) ~= "string" then error(("Internal error: Wrong type %s for glossary value %s for tag %s"):format( type(glossary), dump(glossary), normtag)) else local link = glossary:match("^wikt:(.*)") if link then display = "[[" .. link .. "|" .. display .. "]]" end if not link then link = glossary:match("^w:(.*)") if link then display = "[[w:" .. link .. "|" .. display .. "]]" end end if not link then display = "[[Appendix:Glossary#" .. anchor_encode(glossary) .. "|" .. display .. "]]" end end end end return display end --[==[ Turn a canonicalized tag spec (which describes a single, possibly multipart tag) into the displayed form. The tag spec may be a string (a canonical-form tag); a list of canonical-form tags (in the case of a simple multipart tag); or a list of mixed canonical-form tags and lists of such tags (in the case of a two-level multipart tag). `joiner` indicates how to join the parts of a multipart tag, and can be either {"and"} ("foo and bar", or "foo, bar and baz" for 3 or more), {"slash"} ("foo/bar"), {"en-dash"} ("foo–bar") or {nil}, which uses the global default found in {multipart_join_strategy()} in [[Module:form of/functions]]. (NOTE: The global default is {"slash"} and this seems unlikely to change.) A truthy `nolink` suppresses linking.]==] function export.get_tag_display_form(tagspec, lang, joiner, nolink) if type(tagspec) == "string" then return get_single_tag_display_form(tagspec, lang, nolink) end -- We have a multipart tag. See if there's a display handler to display them specially. for _, handler in ipairs(display_handlers or get_display_handlers()) do local displayval = handler(tagspec, joiner) if displayval then if nolink then displayval = remove_links(displayval) end return displayval end end -- No display handler. local displayed_tags = {} for _, first_level_tag in ipairs(tagspec) do if type(first_level_tag) == "string" then insert(displayed_tags, get_single_tag_display_form(first_level_tag, lang, nolink)) else -- A first-level element of a two-level multipart tag. Currently we just separate the individual components -- with spaces, but other ways are possible, e.g. using an underscore, colon, parens or braces. local components = {} for _, component in ipairs(first_level_tag) do insert(components, get_single_tag_display_form(component, lang, nolink)) end insert(displayed_tags, concat(components, " ")) end end return join_multiparts(displayed_tags, joiner) end get_tag_display_form = export.get_tag_display_form --[==[ Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are represented as lists, and two-level multipart tags as lists of lists), convert to displayed form (a string). See {get_tag_display_form()} for the meaning of `joiner`. A truthy `nolink` suppresses linking.]==] function export.get_tag_set_display_form(normalized_tag_set, lang, joiner, nolink) local parts = {} for _, tagspec in ipairs(normalized_tag_set) do local to_insert = get_tag_display_form(tagspec, lang, joiner, nolink) -- Maybe insert a space before inserting the display form of the tag. We insert a space if -- (a) we're not the first tag; and -- (b) the tag we're about to insert doesn't have the "no_space_on_left" property; and -- (c) the preceding tag doesn't have the "no_space_on_right" property. -- NOTE: We depend here on the fact that -- (1) all tags with either of the above properties set have the same display form as canonical form, and -- (2) all tags with either of the above properties set are single-character tags. -- The second property is an optimization to avoid looking up display forms resulting from multipart tags, -- which won't be found and which will trigger loading of [[Module:form of/data/2]]. If multichar punctuation is -- added in the future, it's ok to change the == 1 below to <= 2 or <= 3. -- -- If the first property above fails to hold in the future, we need to track the canonical form of each tag -- (including the previous one) as well as the display form. This would also avoid the need for the == 1 check. if #parts > 0 then local most_recent_tagobj = parts[#parts]:match("^.[\128-\191]*$") and lookup_tag(parts[#parts], lang) local to_insert_tagobj = to_insert:match("^.[\128-\191]*$") and lookup_tag(to_insert, lang) if ( (not most_recent_tagobj or not most_recent_tagobj.no_space_on_right) and (not to_insert_tagobj or not to_insert_tagobj.no_space_on_left) ) then insert(parts, " ") end end insert(parts, to_insert) end return concat(parts) end get_tag_set_display_form = export.get_tag_set_display_form --[==[ Split a tag set containing two-level multipart tags into one or more tag sets not containing such tags. Single-level multipart tags are left alone. (If we need to, a slight modification of the following code will also split single-level multipart tags.) This assumes that multipart tags are represented as lists and two-level multipart tags are represented as lists of lists, as is output by {normalize_tag_set()}. NOTE: We have to be careful to properly handle imbalanced two-level multipart tags such as `def:s//p` (or the reverse, `s//def:p`).]==] local function split_two_level_multipart_tag_set(tag_set) for i, tag in ipairs(tag_set) do if type(tag) == "table" then -- We saw a multipart tag. Check if any of the parts are two-level. local saw_two_level_tag = false for _, first_level_tag in ipairs(tag) do if type(first_level_tag) == "table" then saw_two_level_tag = true break end end if saw_two_level_tag then -- We found a two-level multipart tag. -- (1) Extract the preceding tags. local pre_tags = slice(tag_set, 1, i - 1) -- (2) Extract the following tags. local post_tags = slice(tag_set, i + 1) -- (3) Loop over each tag set alternant in the two-level multipart tag. -- For each alternant, form the tag set consisting of pre_tags + alternant + post_tags, -- and recursively split that tag set. local resulting_tag_sets = {} for _, first_level_tag_set in ipairs(tag) do local expanded_tag_set = {} extend(expanded_tag_set, pre_tags) -- The second level may have a string or a list. if type(first_level_tag_set) == "table" then extend(expanded_tag_set, first_level_tag_set) else insert(expanded_tag_set, first_level_tag_set) end extend(expanded_tag_set, post_tags) extend(resulting_tag_sets, split_two_level_multipart_tag_set(expanded_tag_set)) end return resulting_tag_sets end end end return {tag_set} end local function try_lang_specific_module(langcode, modules_tried, name, data) local lang_specific_module = form_of_lang_data_module_prefix .. langcode .. "/functions" local langdata = safe_require(lang_specific_module) if langdata then insert(modules_tried, lang_specific_module) if langdata.cat_functions then local fn = langdata.cat_functions[name] if fn then return fn(data), true end end end return nil, false end -- Call a named function, either from the lang-specific data in -- [[Module:form of/lang-specific/LANGCODE/functions]] or in [[Module:form of/functions]]. local function call_named_function(name, funtype, normalized_tag_set, lang, POS, pagename, lemmas) local data = { pagename = pagename or default_pagename or get_default_pagename(), lemmas = lemmas, tag_set = normalized_tag_set, lang = lang, POS = POS } local modules_tried = {} -- First try lang-specific. while lang do local retval, found_it = try_lang_specific_module(lang:getCode(), modules_tried, name, data) if found_it then return retval end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end -- Try lang-independent. insert(modules_tried, form_of_functions_module) local fn = (cat_functions or get_cat_functions())[name] if fn then return fn(data) end for i, modname in ipairs(modules_tried) do modules_tried[i] = "[[" .. modname .. "]]" end error(("No %s function named '%s' in %s"):format(funtype, name, list_to_text(modules_tried, nil, " or "))) end -- Given a tag from the current tag set (which may be a list in case of a multipart tag), -- and a tag from a categorization spec, check that the two match. -- (1) If both are strings, we just check for equality. -- (2) If the spec tag is a string and the tag set tag is a list (i.e. it originates from a -- multipart tag), we check that the spec tag is in the list. This is because we want to treat -- multipart tags in user-specified tag sets as if the user had specified multiple tag sets. -- For example, if the user said "1//3|s|pres|ind" and the categorization spec says {"has", "1"}, -- we want this to match, because "1//3|s|pres|ind" should be treated equivalently to two tag -- sets "1|s|pres|ind" and "3|s|pres|ind", and the former matches the categorization spec. -- (3) If the spec tag is a list (i.e. it originates from a multipart tag), we check that the -- tag set tag is also a list and is a superset of the spec tag. For example, if the categorization -- spec says {"has", "1//3"}, then the tag set tag must be a multipart tag that has both "1" and "3" -- in it. "1//3" works, as does "1//2//3". local function tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) if type(spec_tag) == "table" then if type(tag_set_tag) == "table" and is_subset_list(spec_tag, tag_set_tag) then return true end elseif type(tag_set_tag) == "table" then if contains(tag_set_tag, spec_tag) then return true end elseif tag_set_tag == spec_tag then return true end return false end -- Check that the current tag set matches the given spec tag. This means that any of the tags -- in the current tag set match, according to tag_set_tag_matches_spec_tag(); see above. If the -- current tag set contains only string tags (i.e. no multipart tags), and the spec tag is a -- string (i.e. not a multipart tag), this boils down to list containment, but it gets more -- complex when multipart tags are present. local function tag_set_matches_spec_tag(spec_tag, tag_set, lang) spec_tag = normalize_tag(spec_tag, lang) for _, tag_set_tag in ipairs(tag_set) do if tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) then return true end end return false end -- Check whether the given spec matches the current tag set. Two values are returned: -- (1) whether the spec matches the tag set; (2) the index of the category to add if -- the spec matches. local function check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if type(spec) == "boolean" then return spec elseif type(spec) ~= "table" then error("Wrong type of condition " .. spec .. ": " .. type(spec)) end local predicate = spec[1] if predicate == "has" then return tag_set_matches_spec_tag(spec[2], tag_set, lang), 3 elseif predicate == "hasall" then for _, tag in ipairs(spec[2]) do if not tag_set_matches_spec_tag(tag, tag_set, lang) then return false, 3 end end return true, 3 elseif predicate == "hasany" then for _, tag in ipairs(spec[2]) do if tag_set_matches_spec_tag(tag, tag_set, lang) then return true, 3 end end return false, 3 elseif predicate == "tags=" then local normalized_spec_tag_sets = normalize_tag_set(spec[2], lang) if #normalized_spec_tag_sets > 1 then error("Internal error: No support for conjoined shortcuts in category/label specs in " .. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|")) end local normalized_spec_tag_set = normalized_spec_tag_sets[1] -- Check for and disallow two-level multipart tags in the specs. FIXME: Remove this when we remove -- support for two-level multipart tags. for _, tag in ipairs(normalized_spec_tag_set) do if type(tag) == "table" then for _, subtag in ipairs(tag) do if type(subtag) == "table" then error("Internal error: No support for two-level multipart tags in category/label specs" .. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|")) end end end end -- Allow tags to be in different orders, and multipart tags to be in different orders. To handle this, -- we first check that both tag set tags and spec tags have the same length. If so, we sort the -- multipart tags in the tag set tags and spec tags, and then check that all tags in the spec tags are -- in the tag set tags. if #tag_set ~= #normalized_spec_tag_set then return false, 3 end local tag_set_tags = deep_copy(tag_set) for i=1,#tag_set_tags do if type(tag_set_tags[i]) == "table" then sort(tag_set_tags[i]) end if type(normalized_spec_tag_set[i]) == "table" then sort(normalized_spec_tag_set[i]) end end for i=1,#tag_set_tags do if not contains(tag_set_tags, normalized_spec_tag_set[i]) then return false, 3 end end return true, 3 elseif predicate == "p=" then return POS == normalize_pos(spec[2]), 3 elseif predicate == "pany" then for _, specpos in ipairs(spec[2]) do if POS == normalize_pos(specpos) then return true, 3 end end return false, 3 elseif predicate == "pexists" then return POS ~= nil, 2 elseif predicate == "not" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) return not condval, 3 elseif predicate == "and" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if condval then condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) end return condval, 4 elseif predicate == "or" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if not condval then condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) end return condval, 4 elseif predicate == "call" then return call_named_function(spec[2], "condition", normalized_tag_set, lang, POS, pagename, lemmas), 3 else error("Unrecognized predicate: " .. predicate) end end -- Process a given spec. This checks any conditions in the spec against the -- tag set, and insert any resulting categories into `categories`. Return value -- is true if the outermost condition evaluated to true and a category was inserted -- (this is used in {"cond" ...} conditions, which stop when a subcondition evaluates -- to true). local function process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) if not spec then return false elseif type(spec) == "string" then -- A category. Substitute POS request with user-specified part of speech or default. spec = spec:gsub("<<p=(.-)>>", function(default) return POS or normalize_pos(default) end) insert(categories, lang:getFullName() .. " " .. spec) return true elseif type(spec) == "table" and spec.labels then -- A label spec. for _, label in ipairs(spec.labels) do insert_if_not(labels, label) end return true elseif type(spec) ~= "table" then error("Wrong type of specification " .. spec .. ": " .. type(spec)) end local predicate = spec[1] if predicate == "multi" then for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2. process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end return true elseif predicate == "cond" then for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2. if process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) then return true end end return false elseif predicate == "call" then return process_spec( call_named_function(spec[2], "spec", normalized_tag_set, lang, POS, pagename, lemmas), tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels ) else local condval, ifspec = check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if condval then process_spec(spec[ifspec], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) return true else process_spec(spec[ifspec + 1], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) -- FIXME: Are we sure this is correct? return false end end end --[==[ Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are represented as lists, and two-level multipart tags as lists of lists), fetch the associated categories and labels. Return two values, a list of categories and a list of labels. `lang` is the language of term represented by the tag set, and `POS` is the user-provided part of speech (which may be {nil}).]==] function export.fetch_categories_and_labels(normalized_tag_set, lang, POS, pagename, lemmas) local categories, labels = {}, {} POS = normalize_pos(POS) -- First split any two-level multipart tags into multiple sets, to make our life easier. for _, tag_set in ipairs(split_two_level_multipart_tag_set(normalized_tag_set)) do local langcode = lang:getCode() local langspecs = (m_cats_data or get_m_cats_data())[langcode] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end local full_code = lang:getFullCode() if full_code ~= langcode then local langspecs = (m_cats_data or get_m_cats_data())[full_code] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end end if full_code ~= "und" then local langspecs = (m_cats_data or get_m_cats_data())["und"] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end end end return categories, labels end fetch_categories_and_labels = export.fetch_categories_and_labels local function format_labels(labels, data, notext) if labels and #labels > 0 then return show_labels{ labels = labels, lang = data.lang, sort = data.sort, nocat = data.nocat } .. (notext and (data.pretext or "") == "" and "" or " ") else return "" end end --[==[ Implementation of templates that display inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with the following fields: * `.lang`: ('''''required''''') Language to use when looking up language-specific inflection tags, categories and labels, and for displaying categories and labels. * `.tags`: ('''''required''' unless `.tag_sets` is given'') List of non-canonicalized inflection tags. Multiple tag sets can be indicated by a {";"} as one of the tags, and tag-set properties may be attached to the last tag of a tag set. The tags themselves may come directly from the user (as in {{tl|inflection of}}); come partly from the user (as in {{tl|participle of}}, which adds the tag `part` to user-specified inflection tags); or be entirely specified by the template (as in {{tl|past participle of}}). * `.tag_sets`: ('''''required''' unless `.tags` is given'') List of non-canonicalized tag sets and associated per-tag-set properties. Each element of the list is an object of the form { {tags = {"TAG", "TAG", ...}, labels = {"LABEL", "LABEL", ...}}. If `.tag_sets` is specified, `.tags` should not be given and vice-versa. Specifying `.tag_sets` in place of tags allowed per-tag set labels to be specified; otherwise, there is no advantage. [[Module:pt-gl-inflections]] uses this functionality to supply labels like {"Brazil"} and {"Portugal"} associated with specific tag sets. * `.lemmas`: ('''''recommended''''') List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly. If omitted entirely, no lemma links are shown and the connecting "of" is also omitted. * `.lemma_face`: ('''''recommended''''') "Face" to use when displaying the lemma objects. Usually should be set to {"term"}. * `.POS`: ('''''recommended''''') Categorizing part-of-speech tag. Comes from the {{para|p}} or {{para|POS}} argument of {{tl|inflection of}}. * `.pagename`: Page name of "current" page or nil to use the actual page title; for testing purposes. * `.conj`: Conjunction or separator to use when joining multiple lemma objects. Defaults to {"and"}. * `.enclitics`: List of enclitics to display after the lemmas, in parens. * `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}. * `.no_format_categories`: If true, don't format the categories derived from the inflection tags; just return them. * `.sort`: Sort key for formatted categories. Ignored when `.no_format_categories` = {true}. * `.nocat`: Suppress computation of categories (even if `.no_format_categories` is not given). * `.notext`: Disable display of all tag text and `inflection of` text. (FIXME: Maybe not implemented correctly.) * `.nolink`: Suppress linking of terms in inflection tags. * `.capfirst`: Capitalize the first word displayed. * `.pretext`: Additional text to display before the inflection tags, but after any top-level labels. * `.posttext`: Additional text to display after the lemma links. * `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is {"form-of-definition use-with-mention"}. * `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}. * `.joiner`: Override the joiner (normally a slash) used to join multipart tags. You should normally not specify this. * `.nowrap`: Do not wrap the form-of definitions in a span, unless `.text_classes` is specified. * `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified in-place to save memory; otherwise they will be copied before modifying. A typical call might look like this (for {{m+|es|amo}}): { local lang = require("Module:languages").getByCode("es") local lemma_obj = { lang = lang, term = "amar", } return m_form_of.tagged_inflections({ lang = lang, tags = {"1", "s", "pres", "ind"}, lemmas = {lemma_obj}, lemma_face = "term", POS = "verb" }) } Normally, one value is returned, the formatted text, which has appended to it the formatted categories derived from the tag-set-related categories generated by the specs in [Module:form of/cats]]. To suppress this, set `data.no_format_categories` = {true}, in which case two values are returned, the formatted text without any formatted categories appended and a list of the categories to be formatted. NOTE: There are two sets of categories that may be generated: (1) categories derived directly from the tag sets, as specified in [[Module:form of/cats]]; (2) categories derived from tag-set labels, either (a) set explicitly by the caller in `data.tag_sets`, (b) specified by the user using `<lb:...>` attached to the last tag in a tag set, or (c) specified in [[Module:form of/cats]]. The second type (label-related categories) are currently not returned in the second return value of {tagged_inflections()}, and are currently inserted into the output text even if `data.no_format_categories` is set to {true}; but they can be suppressed by setting `data.nocat` = {true} (which also suppresses the first type of categories, those derived directly from tag sets, even if `data.no_format_categories` is set to {true}).]==] function export.tagged_inflections(data) if not data.tags and not data.tag_sets then error("First argument must be a table of arguments, and `.tags` or `.tag_sets` must be specified") end if data.tags and data.tag_sets then error("Both `.tags` and `.tag_sets` cannot be specified") end local tag_sets = data.tag_sets if not tag_sets then tag_sets = split_tag_set(data.tags) for i, tag_set in ipairs(tag_sets) do tag_sets[i] = parse_tag_set_properties(tag_set) end end local inflections = {} local categories = {} for _, tag_set in ipairs(tag_sets) do local normalized_tag_sets = normalize_tag_set(tag_set.tags, data.lang, "do-track") for _, normalized_tag_set in ipairs(normalized_tag_sets) do local this_categories, this_labels = fetch_categories_and_labels(normalized_tag_set, data.lang, data.POS, data.pagename, type(data.lemmas) == "table" and data.lemmas or nil) if not data.nocat then extend(categories, this_categories) end local cur_infl = get_tag_set_display_form(normalized_tag_set, data.lang, data.joiner, data.nolink) if #cur_infl > 0 then if tag_set.labels then this_labels = append(tag_set.labels, this_labels) end insert(inflections, {infl_text = cur_infl, labels = this_labels}) end end end local overall_labels, need_per_tag_set_labels for _, inflection in ipairs(inflections) do if overall_labels == nil then overall_labels = inflection.labels elseif not deep_equals(overall_labels, inflection.labels) then need_per_tag_set_labels = true overall_labels = nil break end end if not need_per_tag_set_labels then for _, inflection in ipairs(inflections) do inflection.labels = nil end end local format_data = shallow_copy(data) local of_text = data.lemmas and " of" or "" local formatted_text, this_categories if #inflections == 1 then if need_per_tag_set_labels then error("Internal error: need_per_tag_set_labels should not be set with one inflection") end format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or ((data.capfirst and ucfirst(inflections[1].infl_text) or inflections[1].infl_text) .. of_text)) formatted_text, this_categories = format_form_of(format_data) else format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or ((data.capfirst and "Inflection" or "inflection") .. of_text)) format_data.posttext = (data.posttext or "") .. ":" local link link, this_categories = format_form_of(format_data) local text_classes = data.text_classes if text_classes == nil and not data.nowrap then text_classes = "form-of-definition use-with-mention" end for i, inflection in ipairs(inflections) do inflections[i] = "\n## " .. format_labels(inflection.labels, data, false) .. wrap_in_span(inflection.infl_text, text_classes) end formatted_text = link .. concat(inflections) end if this_categories[1] then extend(categories, this_categories) end if not data.no_format_categories then if categories[1] then formatted_text = formatted_text .. format_categories(categories, data.lang, data.sort, nil, export.force_cat) end return formatted_text end return formatted_text, categories end function export.dump_form_of_data(_frame) local data = { require(form_of_data1_module), require(form_of_data2_module) } return require(json_module).toJSON(data) end export.form_of_cats_module = form_of_cats_module export.form_of_data1_module = form_of_data1_module export.form_of_data2_module = form_of_data2_module export.form_of_functions_module = form_of_functions_module export.form_of_lang_data_module_prefix = form_of_lang_data_module_prefix export.headword_data_module = headword_data_module -- so all form-of modules stay in sync return export 537y0z5vf78rgvzdvy0emj66k9afncd 238978 238977 2026-11-14T03:00:43Z Lee 19 [[:en:Module:form_of]] වෙතින් එක් සංශෝධනයක් 238977 Scribunto text/plain local export = {} export.force_cat = false -- for testing; set to true to display categories even on non-mainspace pages local debug_track_module = "Module:debug/track" local etymology_module = "Module:etymology" local form_of_cats_module = "Module:form of/cats" local form_of_data_module = "Module:form of/data" local form_of_data1_module = "Module:form of/data/1" local form_of_data2_module = "Module:form of/data/2" local form_of_functions_module = "Module:form of/functions" local form_of_lang_data_module_prefix = "Module:form of/lang-data/" local function_module = "Module:fun" local headword_data_module = "Module:headword/data" local json_module = "Module:JSON" local labels_module = "Module:labels" local links_module = "Module:links" local load_module = "Module:load" local parse_utilities_module = "Module:parse utilities" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local table_deep_equals_module = "Module:table/deepEquals" local utilities_module = "Module:utilities" local anchor_encode = mw.uri.anchorEncode local concat = table.concat local dump = mw.dumpObject local fetch_categories_and_labels -- Defined below. local format_form_of -- Defined below. local get_tag_display_form -- Defined below. local get_tag_set_display_form -- Defined below. local insert = table.insert local ipairs = ipairs local is_link_or_html -- Defined below. local list_to_text = mw.text.listToText local lookup_shortcut -- Defined below. local lookup_tag -- Defined below. local normalize_tag_set -- Defined below. local parse_tag_set_properties -- Defined below. local require = require local sort = table.sort local split_tag_set -- Defined below. local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function append(...) append = require(table_module).append return append(...) end local function contains(...) contains = require(table_module).contains return contains(...) end local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) end local function deep_equals(...) deep_equals = require(table_deep_equals_module) return deep_equals(...) end local function extend(...) extend = require(table_module).extend return extend(...) end local function format_categories(...) format_categories = require(utilities_module).format_categories return format_categories(...) end local function full_link(...) full_link = require(links_module).full_link return full_link(...) end local function insert_if_not(...) insert_if_not = require(table_module).insertIfNot return insert_if_not(...) end local function is_subset_list(...) is_subset_list = require(table_module).isSubsetList return is_subset_list(...) end local function iterate_from(...) iterate_from = require(function_module).iterateFrom return iterate_from(...) end local function join_multiparts(...) join_multiparts = require(form_of_functions_module).join_multiparts return join_multiparts(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function parse_inline_modifiers(...) parse_inline_modifiers = require(parse_utilities_module).parse_inline_modifiers return parse_inline_modifiers(...) end local function remove_links(...) remove_links = require(links_module).remove_links return remove_links(...) end local function safe_load_data(...) safe_load_data = require(load_module).safe_load_data return safe_load_data(...) end local function safe_require(...) safe_require = require(load_module).safe_require return safe_require(...) end local function serial_comma_join(...) serial_comma_join = require(table_module).serialCommaJoin return serial_comma_join(...) end local function shallow_copy(...) shallow_copy = require(table_module).shallowCopy return shallow_copy(...) end local function show_labels(...) show_labels = require(labels_module).show_labels return show_labels(...) end local function slice(...) slice = require(table_module).slice return slice(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function ucfirst(...) ucfirst = require(string_utilities_module).ucfirst return ucfirst(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local cat_functions local function get_cat_functions() cat_functions, get_cat_functions = require(form_of_functions_module).cat_functions, nil return cat_functions end local default_pagename local function get_default_pagename() default_pagename, get_default_pagename = load_data(headword_data_module).pagename, nil return default_pagename end local display_handlers local function get_display_handlers() display_handlers, get_display_handlers = require(form_of_functions_module).display_handlers, nil return display_handlers end local m_cats_data local function get_m_cats_data() m_cats_data, get_m_cats_data = load_data(form_of_cats_module), nil return m_cats_data end local m_data local function get_m_data() -- Needs require. m_data, get_m_data = require(form_of_data_module), nil return m_data end local m_data1 local function get_m_data1() m_data1, get_m_data1 = load_data(form_of_data1_module), nil return m_data1 end local m_data2 local function get_m_data2() m_data2, get_m_data2 = load_data(form_of_data2_module), nil return m_data2 end local m_pos_data local function get_m_pos_data() m_pos_data, get_m_pos_data = load_data(headword_data_module).pos_aliases, nil return m_pos_data end --[==[ intro: This module implements the underlying processing of {{tl|form of}}, {{tl|inflection of}} and specific variants such as {{tl|past participle of}} and {{tl|alternative spelling of}}. Most of the logic in this file is to handle tags in {{tl|inflection of}}. Other related files: * [[Module:form of/templates]] contains the majority of the logic that implements the templates themselves. * [[Module:form of/data/1]] is a data-only file containing information on the more common inflection tags, listing the tags, their shortcuts, the category they belong to (tense-aspect, case, gender, voice-valence, etc.), the appropriate glossary link and the wikidata ID. * [[Module:form of/data/2]] is a data-only file containing information on the less common inflection tags, in the same format as [[Module:form of/data/1]]. * [[Module:form of/lang-data/LANGCODE]] is a data-only file containing information on the language-specific inflection tags for the language with code LANGCODE, in the same format as [[Module:form of/data/1]]. Language-specific tags override general tags. * [[Module:form of/cats]] is a data-only file listing the language-specific categories that are added when the appropriate combinations of tags are seen for a given language. * [[Module:form of/functions]] contains functions for use with [[Module:form of/data/1]] and [[Module:form of/cats]]. They are contained in this module because data-only modules can't contain code. The functions in this file are of two types: *# Display handlers allow for customization of the display of multipart tags (see below). Currently there is only one such handler, for handling multipart person tags such as `1//2//3`. *# Cat functions allow for more complex categorization logic, and are referred to by name in [[Module:form of/cats]]. Currently no such functions exist. The following terminology is used in conjunction with {{tl|inflection of}}: * A ''tag'' is a single grammatical item, as specified in a single numbered parameter of {{tl|inflection of}}. Examples are `masculine`, `nominative`, or `first-person`. Tags may be abbreviated, e.g. `m` for `masculine`, `nom` for `nominative`, or `1` for `first-person`. Such abbreviations are called ''aliases'', and some tags have multiple equivalent aliases (e.g. `p` or `pl` for `plural`). The full, non-abbreviated form of a tag is called its ''canonical form''. * The ''display form'' of a tag is the way it's displayed to the user. Usually the displayed text of the tag is the same as its canonical form, and it normally functions as a link to a glossary entry explaining the tag. Usually the link is to an entry in [[Appendix:Glossary]], but sometimes the tag is linked to an individual dictionary entry or to a Wikipedia entry. Occasionally, the display text differs from the canonical form of the tag. An example is the tag `comparative case`, which has the display text read as simply `comparative`. Normally, tags referring to cases don't have the word "case" in them, but in this case the tag `comparative` was already used as an alias for the tag `comparative degree`, so the tag was named `comparative case` to avoid clashing. A similar situation occurs with `adverbial case` vs. the grammar tag `adverbial` (as in `adverbial participle`). * A ''tag set'' is an ordered list of tags, which together express a single inflection, for example, `1|s|pres|ind`, which can be expanded to canonical-form tags as `first-person|singular|present|indicative`. * A ''conjoined tag set'' is a tag set that consists of multiple individual tag sets separated by a semicolon, e.g. `1|s|pres|ind|;|2|s|imp`, which specifies two tag sets, `1|s|pres|ind` as above and `2|s|imp` (in canonical form, `second-person|singular|imperative`). Multiple tag sets specified in a single call to {{tl|inflection of}} are specified in this fashion. Conjoined tag sets can also occur in list-tag shortcuts. * A ''multipart tag'' is a tag that embeds multiple tags within it, such as `f//n` or `nom//acc//voc`. These are used in the case of [[syncretism]], when the same form applies to multiple inflections. Examples are the Spanish present subjunctive, where the first-person and third-person singular have the same form (e.g. {{m|es|siga}} from {{m|es|seguir|t=to follow}}), or Latin third-declension adjectives, where the dative and ablative plural of all genders have the same form (e.g. {{m|la|omnibus}} from {{m|la|omnis|t=all}}). These would be expressed respectively as `1//3|s|pres|sub` and `dat//abl|m//f//n|p`, where the use of the multipart tag compactly encodes the syncretism and avoids the need to individually list out all of the inflections. Multipart tags currently display as a list separated by a slash, e.g. ''dative/ablative'' or ''masculine/feminine/neuter'' where each individual word is linked appropriately. As a special case, multipart tags involving persons display specially; for example, the multipart tag `1//2//3` displays as ''first-, second- and third-person'', with the word "person" occurring only once. * A ''two-level multipart tag'' is a special type of multipart tag that joins two or more tag sets instead of joining individual tags. The tags within the tag set are joined by a colon, e.g. `1:s//3:p`, which is displayed as ''first-person singular and third-person plural'', e.g. for use with the form {{m|grc|μέλλον}} of the verb {{m|grc|μέλλω|t=to intend}}, which uses the tag set `1:s//3:p|impf|actv|indc|unaugmented` to express the syncretism between the first singular and third plural forms of the imperfect active indicative unaugmented conjugation. Two-level multipart tags should be used sparingly; if in doubt, list out the inflections separately. [FIXME: Make two-level multipart tags obsolete.] * A ''shortcut'' is a tag that expands to any type of tag described above, or to any type of tag set described above. Aliases are a particular type of shortcut whose expansion is a single non-multipart tag. * A ''multipart shortcut'' is a shortcut that expands into a multipart tag, for example `123`, which expands to the multipart tag `1//2//3`. Only the most common such combinations exist as shortcuts. * A ''list shortcut'' is a special type of shortcut that expands to a list of tags instead of a single tag. For example, the shortcut `1s` expands to `1|s` (first-person singular). Only the most common such combinations exist as shortcuts. * A ''conjoined shortcut'' is a special type of list shortcut that consists of a conjoined tag set (multiple logical tag sets). For example, the English language-specific shortcut `ed-form` expands to `spast|;|past|part`, expressing the common syncretism between simple past and past participle in English (and in this case, `spast` is itself a list shortcut that expands to `simple|past`).]==] -- Add tracking category for PAGE when called from {{inflection of}} or -- similar TEMPLATE. The tracking category linked to is -- [[Wiktionary:Tracking/inflection of/PAGE]]. local function track(page) debug_track("inflection of/" .. -- avoid including links in pages (may cause error) page:gsub("%[", "("):gsub("%]", ")"):gsub("|", "!") ) end local function wrap_in_span(text, classes) if classes then return ("<span class='%s'>%s</span>"):format(classes, text) else return text end end local function show_linked_term(data) local termobj, face, span_classes, ok_to_destructively_modify, overall_lang, text_classes = data.termobj, data.face, data.span_classes, data.ok_to_destructively_modify, data.overall_lang, data.text_classes local need_to_copy, pretext_lang local categories = {} if overall_lang and overall_lang:getCode() ~= termobj.lang:getCode() then local lang_display lang_display, categories = require(etymology_module).insert_source_cat_get_display { lang = data.overall_lang, source = termobj.lang, } pretext_lang = wrap_in_span(lang_display .. " ", text_classes) end local has_decoration = termobj.q or termobj.qq or termobj.a or termobj.aa or termobj.l or termobj.ll or termobj.refs -- `show_decorations` is set by parse_{term,list}_with_inline_modifiers_and_separate_params in -- [[Module:parameter utilities]], called in [[Module:form of/templates]], so in most circumstances -- it's already set and we don't need to do a shallow-copy to set it. local need_to_set_show_decorations = has_decoration and not termobj.show_decorations need_to_copy = not ok_to_destructively_modify and (pretext_lang or need_to_set_show_decorations) if need_to_copy then termobj = shallow_copy(termobj) end if pretext_lang then termobj.pretext = pretext_lang end if need_to_set_show_decorations then termobj.show_decorations = true end return wrap_in_span(full_link(termobj, face), span_classes), categories end --[==[ Lowest-level implementation of form-of templates, including the general {{tl|form of}} as well as those that deal with inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with the following fields: * `.lang`: Overall language of the form-of template. If specified, any lemmas, enclitics or base lemmas that are of a different language will have that language displayed before the term in question. * `.text`: Text to insert before the lemmas. Wrapped in the value of `.text_classes`, or its default; see below. * `.lemmas`: List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly, or omitted, to show no lemma links and omit the connecting text. * `.lemma_face`: "Face" to use when displaying the lemma objects. Usually should be set to {"term"}. * `.conj`: Conjunction or separator to use when joining multiple lemma objects. If {nil}, defaults to {"and"}. If this has the value {false}, the lemmas are preceded with the `.separator` field in each lemma. * `.enclitics`: List of enclitics to display after the lemmas, in parens. * `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}. * `.base_lemmas`: List of base lemmas to display after the lemmas, in the case where the lemmas in `.lemmas` are themselves forms of another lemma (the base lemma), e.g. a comparative, superlative or participle. Each object is of the form { { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, conj = "CONJ" }} where PARAM_OBJ describes the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas); LEMMA_OBJ is an object suitable to be passed to {full_link()} in [[Module:links]]; and CONJ is the conjunction to join multiple lemmas with, defaulting to {"and"}. PARAM_OBJ is of the format { { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{tl|inflection of}} etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as { {"comd"}} or { {"past", "part"}}. * `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is {"form-of-definition use-with-mention"}. Use `false` for no wrapping. * `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}. Use `false` for no wrapping. * `.posttext`: Additional text to display after the lemma links. * `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified in-place to save memory; otherwise they will be copied before modifying. Returns two values, the formatted string and any categories to add the page to (which will arise if `.lang` is specified and a language other than `.lang` is given in one of the lemmas in `.lemmas` or enclitics in `.enclitics`). ]==] function export.format_form_of(data) if type(data) ~= "table" then error("Internal error: First argument must now be a table of arguments") end local text_classes = data.text_classes if text_classes == nil and not data.nowrap then text_classes = "form-of-definition use-with-mention" end local lemma_classes = data.lemma_classes if lemma_classes == nil then lemma_classes = "form-of-definition-link" end local parts = {} if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end insert(parts, data.text) if data.text ~= "" and data.lemmas then insert(parts, " ") end local categories = {} if data.lemmas then if type(data.lemmas) == "string" then insert(parts, wrap_in_span(data.lemmas, lemma_classes)) else local formatted_terms = {} for _, lemma in ipairs(data.lemmas) do local linked_term, this_categories = show_linked_term { termobj = lemma, face = data.lemma_face, span_classes = lemma_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, overall_lang = data.lang, text_classes = text_classes } if this_categories[1] then extend(categories, this_categories) end if data.conj == false and lemma.separator then insert(formatted_terms, lemma.separator) end insert(formatted_terms, linked_term) end if data.conj == false then insert(parts, concat(formatted_terms)) else insert(parts, serial_comma_join(formatted_terms, {conj = data.conj or "and"})) end end if data.lit then insert(parts, ", literally " .. require(links_module).mark(data.lit, "gloss")) end end if data.enclitics and #data.enclitics > 0 then -- The outer parens need to be outside of the text_classes span so they show in upright instead of italic, or -- they will clash with upright parens generated by link annotations such as transliterations and pos=. if text_classes then insert(parts, "</span>") end local formatted_terms = {} for _, enclitic in ipairs(data.enclitics) do -- FIXME, should we have separate clitic face and/or classes? local linked_term, this_categories = show_linked_term { termobj = enclitic, face = data.lemma_face, span_classes = lemma_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, overall_lang = data.lang, text_classes = text_classes } if this_categories[1] then extend(categories, this_categories) end insert(formatted_terms, linked_term) end insert(parts, " (") insert(parts, wrap_in_span("with enclitic" .. (#data.enclitics > 1 and "s" or "") .. " ", text_classes)) insert(parts, serial_comma_join(formatted_terms, {conj = data.enclitic_conj or "and"})) insert(parts, ")") if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end end if data.base_lemmas and #data.base_lemmas > 0 then for _, base_lemma in ipairs(data.base_lemmas) do insert(parts, ", the ") if text_classes then insert(parts, "</span>") end insert(parts, (export.tagged_inflections { lang = data.lang or base_lemma.lemmas[1].lang, tags = base_lemma.paramobj.tags, lemmas = base_lemma.lemmas, conj = base_lemma.conj or "and", lemma_face = data.lemma_face, no_format_categories = true, nocat = true, text_classes = data.text_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, })) if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end end end -- FIXME, should posttext go before enclitics? If so we need to have separate handling for the -- final colon when there are multiple tag sets in tagged_inflections(). if data.posttext then insert(parts, data.posttext) end if text_classes then insert(parts, "</span>") end return concat(parts), categories end format_form_of = export.format_form_of --[==[ Return true if `tag` contains an internal link or HTML.]==] function export.is_link_or_html(tag) return tag:find("[[", nil, true) or tag:find("|", nil, true) or tag:find("<", nil, true) end is_link_or_html = export.is_link_or_html --[==[ Look up a tag (either a shortcut of any sort of a canonical long-form tag) and return its expansion. The expansion will be a string unless the shortcut is a list-tag shortcut such as `1s`; in that case, the expansion will be a list. The caller must handle both cases. Only one level of expansion happens; hence, `acc` expands to {"accusative"}, `1s` expands to { {"1", "s"}} (not to { {"first", "singular"}}) and `123` expands to {"1//2//3"}. The expansion will be the same as the passed-in tag in the following circumstances: # The tag is `;` (this is special-cased, and no lookup is done). # The tag is a multipart tag such as `nom//acc` (this is special-cased, and no lookup is done). # The tag contains a raw link (this is special-cased, and no lookup is done). # The tag contains HTML (this is special-cased, and no lookup is done). # The tag is already a canonical long-form tag. # The tag is unrecognized. This function first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in [[Module:form of/data/1]] (which includes more common non-lang-specific tags) and finally (only if the tag is not recognized as a shortcut or canonical tag, and is not of types 1-4 above) in [[Module:form of/data/2]]. If the expansion is a string and is different from the tag, track it if `do_track` is true.]==] function export.lookup_shortcut(tag, lang, do_track) -- If there is HTML or a link in the tag, return it directly; don't try -- to look it up, which will fail. if tag == ";" or tag:find("//", nil, true) or is_link_or_html(tag) then return tag end local expansion while lang do local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode()) -- If this is a canonical long-form tag, just return it, and don't check for shortcuts. This is an -- optimization; see below. if langdata then if langdata.tags[tag] then return tag end expansion = langdata.shortcuts[tag] if expansion then break end end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end if not expansion then -- If this is a canonical long-form tag, just return it, and don't check for shortcuts (which will cause -- [[Module:form of/data/2]] to be loaded, because there won't be a shortcut entry in [[Module:form of/data/1]] -- -- or, for that matter, in [[Module:form of/data/2]]). This is an optimization; the code will still work without -- it, but will use up more memory. if (m_data1 or get_m_data1()).tags[tag] then return tag end expansion = m_data1.shortcuts[tag] end if not expansion then expansion = (m_data2 or get_m_data2()).shortcuts[tag] end if not expansion then return tag end -- Maybe track the expansion if it's not the same as the raw tag. if do_track and expansion ~= tag and type(expansion) == "string" then track("tag/" .. tag) end return expansion end lookup_shortcut = export.lookup_shortcut --[==[ Look up a normalized/canonicalized tag and return the data object associated with it. If the tag isn't found, return nil. This first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in [[Module:form of/data/1]] (which includes more common non-lang-specific tags) and then finally in [[Module:form of/data/2]].]==] function export.lookup_tag(tag, lang) while lang do local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode()) local tag = langdata and langdata.tags[tag] if tag then return tag end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end local tagobj = (m_data1 or get_m_data1()).tags[tag] if tagobj then return tagobj end local tagobj2 = (m_data2 or get_m_data2()).tags[tag] if tagobj2 then return tagobj2 end return nil end lookup_tag = export.lookup_tag -- Normalize a single tag, which may be a shortcut but should not be a multipart tag, a multipart shortcut or a list -- shortcut. local function normalize_single_tag(tag, lang, do_track) local expansion = lookup_shortcut(tag, lang, do_track) if type(expansion) ~= "string" then error("Tag '" .. tag .. "' is a list shortcut, which is not allowed here") end tag = expansion if not lookup_tag(tag, lang) and do_track then -- If after all expansions and normalizations we don't recognize the canonical tag, track it. track("unknown") track("unknown/" .. tag) end return tag end --[=[ Normalize a component of a multipart tag. This should not have any // in it, but may join multiple individual tags with a colon, and may be a single list-tag shortcut, which is treated as if colon-separated. The return value may be a list of tags. ]=] local function normalize_multipart_component(tag, lang, do_track) -- If there is HTML or a link in the tag, don't try to split on colon. A colon may legitimately occur in either one, -- and we don't want these things parsed. Note that we don't do this check before splitting on //, which we don't -- expect to occur in links or HTML; see comment in normalize_tag(). if is_link_or_html(tag) then return tag end local components = split(tag, ":", true) if #components == 1 then -- We allow list-tag shortcuts inside of multipart tags, e.g. -- '1s//3p'. Check for this now. tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then -- Temporary tracking as we will disallow this. track("list-tag-inside-of-multipart") -- We found a list-tag shortcut; treat as if colon-separated. components = tag else return normalize_single_tag(tag, lang, do_track) end end local normtags = {} -- Temporary tracking as we will disallow this. track("two-level-multipart") for _, component in ipairs(components) do if do_track then -- There are multiple components; track each of the individual -- raw tags. track("tag/" .. component) end insert(normtags, normalize_single_tag(component, lang, do_track)) end return normtags end --[=[ Normalize a single tag. The return value may be a list (in the case of multipart tags), which will contain nested lists in the case of two-level multipart tags. ]=] local function normalize_tag(tag, lang, do_track) -- We don't check for links or HTML before splitting on //, which we don't expect to occur in links or HTML. Doing -- it this way allows for a tag like '{{lb|grc|Epic}}//{{lb|grc|Ionic}}' to function correctly (the template calls -- will be expanded before we process the tag, and will contain links and HTML). The only check we do is for a URL, -- which shouldn't normally occur, but might if the user tries to put an external link into the tag. URL's with // -- normally have the sequence ://, which should never normally occur when // and : are used in their normal ways. if tag:find("://", nil, true) then return tag end local split_tags = split(tag, "//", true) if #split_tags == 1 then local retval = normalize_multipart_component(tag, lang, do_track) if type(retval) == "table" then -- The user gave a tag like '1:s', i.e. with colon but without //. Allow this, but we need to return a -- nested list. return {retval} end return retval end local normtags = {} for _, single_tag in ipairs(split_tags) do if do_track then -- If the tag was a multipart tag, track each of individual raw tags. track("tag/" .. single_tag) end insert(normtags, normalize_multipart_component(single_tag, lang, do_track)) end return normtags end --[==[ Normalize a tag set (a list of tags) into its canonical-form tags. The return value is a list of normalized tag sets (a list because of there may be conjoined shortcuts among the input tags). A normalized tag set is a list of tag elements, where each element is either a string (the canonical form of a tag), a list of such strings (in the case of multipart tags) or a list of lists of such strings (in the case of two-level multipart tags). For example, the multipart tag `nom//acc//voc` will be represented in canonical form as { {"nominative", "accusative", "vocative"}}, and the two-level multipart tag `1:s//3:p` will be represented as { {{"first-person", "singular"}, {"third-person", "plural"}}}. Example 1: {normalize_tag_set({"nom//acc//voc", "n", "p"})} = { {{{"nominative", "accusative", "vocative"}, "masculine", "plural"}}} Example 2: {normalize_tag_set({"ed-form"}, ENGLISH)} = { {{"simple", "past"}, {"past", "participle"}}} Example 3: {normalize_tag_set({"archaic", "ed-form"}, ENGLISH)} = { {{"archaic", "simple", "past"}, {"archaic", "past", "participle"}}}]==] function export.normalize_tag_set(tag_set, lang, do_track) -- We track usage of shortcuts, normalized forms and (in the case of multipart tags or list tags) intermediate -- forms. For example, if the tags 1s|mn|gen|indefinite are passed in, we track the following: -- [[Wiktionary:Tracking/inflection of/tag/1s]] -- [[Wiktionary:Tracking/inflection of/tag/1]] -- [[Wiktionary:Tracking/inflection of/tag/s]] -- [[Wiktionary:Tracking/inflection of/tag/first-person]] -- [[Wiktionary:Tracking/inflection of/tag/singular]] -- [[Wiktionary:Tracking/inflection of/tag/mn]] -- [[Wiktionary:Tracking/inflection of/tag/m//n]] -- [[Wiktionary:Tracking/inflection of/tag/m]] -- [[Wiktionary:Tracking/inflection of/tag/n]] -- [[Wiktionary:Tracking/inflection of/tag/masculine]] -- [[Wiktionary:Tracking/inflection of/tag/neuter]] -- [[Wiktionary:Tracking/inflection of/tag/gen]] -- [[Wiktionary:Tracking/inflection of/tag/genitive]] -- [[Wiktionary:Tracking/inflection of/tag/indefinite]] local output_tag_set = {} local saw_semicolon = false for _, tag in ipairs(tag_set) do if do_track then -- Track the raw tag. track("tag/" .. tag) end -- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list -- of tags). tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then if contains(tag, ";") then -- If we saw a conjoined shortcut, we need to use a more general algorithm that can expand a single -- tag set into multiple. saw_semicolon = true break end for _, t in ipairs(tag) do if do_track then -- If the tag expands to a list of raw tags, track each of those. track("tag/" .. t) end insert(output_tag_set, normalize_tag(t, lang, do_track)) end else insert(output_tag_set, normalize_tag(tag, lang, do_track)) end end if not saw_semicolon then return {output_tag_set} end -- Use a more general algorithm that handles conjoined shortcuts. output_tag_set = {} for i, tag in ipairs(tag_set) do if do_track then -- Track the raw tag. track("tag/" .. tag) end -- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list -- of tags). tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then local output_tag_sets = {} local shortcut_tag_sets = split_tag_set(tag) local normalized_shortcut_tag_sets = {} for _, shortcut_tag_set in ipairs(shortcut_tag_sets) do extend(normalized_shortcut_tag_sets, normalize_tag_set(shortcut_tag_set, lang, do_track)) end local after_tags = slice(tag_set, i + 1) local normalized_after_tags_sets = normalize_tag_set(after_tags, lang, do_track) for _, normalized_shortcut_tag_set in ipairs(normalized_shortcut_tag_sets) do for _, normalized_after_tags_set in ipairs(normalized_after_tags_sets) do insert(output_tag_sets, append(output_tag_set, normalized_shortcut_tag_set, normalized_after_tags_set)) end end return output_tag_sets else insert(output_tag_set, normalize_tag(tag, lang, do_track)) end end error("Internal error: Should not get here") end normalize_tag_set = export.normalize_tag_set --[==[ Split a tag set that may consist of multiple semicolon-separated tag sets into the component tag sets.]==] function export.split_tag_set(tag_set) local split_tag_sets = {} local cur_tag_set = {} for _, tag in ipairs(tag_set) do if tag == ";" then if #cur_tag_set > 0 then insert(split_tag_sets, cur_tag_set) end cur_tag_set = {} else insert(cur_tag_set, tag) end end if #cur_tag_set > 0 then insert(split_tag_sets, cur_tag_set) end return split_tag_sets end split_tag_set = export.split_tag_set local tag_set_param_mods = { lb = { item_dest = "labels", convert = function(arg, _parse_err) return split(arg, "//", true) end, } } --[==[ Parse tag set properties from a tag set (list of tags). Currently no per-tag properties are recognized, and the only per-tag-set property recognized is `<lb:...>` for specifing label(s) for the tag set. Per-tag-set properties must be attached to the last tag.]==] function export.parse_tag_set_properties(tag_set) local function generate_tag_set_obj(last_tag) tag_set[#tag_set] = last_tag return {tags = tag_set} end local last_tag = tag_set[#tag_set] -- Check for inline modifier, e.g. מרים<tr:Miryem>. But exclude HTML entry with <span ...>, <i ...>, <br/> or -- similar in it, caused by wrapping an argument in {{l|...}}, {{af|...}} or similar. Basically, all tags of -- the sort we parse here should consist of a less-than sign, plus letters, plus a colon, e.g. <lb:...>, so if -- we see a tag on the outer level that isn't in this format, we don't try to parse it. The restriction to the -- outer level is to allow generated HTML inside of e.g. qualifier tags, such as foo<q:similar to {{m|fr|bar}}>. if last_tag:find("<", nil, true) and not last_tag:find("^[^<]*<%l*[^%l:]") then return parse_inline_modifiers(last_tag, { param_mods = tag_set_param_mods, generate_obj = generate_tag_set_obj, }) else return generate_tag_set_obj(last_tag) end end parse_tag_set_properties = export.parse_tag_set_properties local function normalize_pos(pos) if not pos then return nil end return (m_pos_data or get_m_pos_data())[pos] or pos end -- Return the display form of a single canonical-form tag. The value -- passed in must be a string (i.e. it cannot be a list describing a -- multipart tag). To handle multipart tags, use get_tag_display_form(). -- A truthy `nolink` suppresses linking. local function get_single_tag_display_form(normtag, lang, nolink) local data = lookup_tag(normtag, lang) local display = normtag -- If the tag has a special display form, use it if data and data.display then display = data.display if nolink then display = remove_links(display) end end -- If there is a nonempty glossary index, then show a link to it if not nolink then local glossary = data and data[(m_data or get_m_data()).GLOSSARY] if glossary ~= nil then if glossary == m_data.WIKT then display = "[[" .. normtag .. "|" .. display .. "]]" elseif glossary == m_data.WP then display = "[[w:" .. normtag .. "|" .. display .. "]]" elseif glossary == m_data.APPENDIX then display = "[[Appendix:Glossary#" .. anchor_encode(normtag) .. "|" .. display .. "]]" elseif type(glossary) ~= "string" then error(("Internal error: Wrong type %s for glossary value %s for tag %s"):format( type(glossary), dump(glossary), normtag)) else local link = glossary:match("^wikt:(.*)") if link then display = "[[" .. link .. "|" .. display .. "]]" end if not link then link = glossary:match("^w:(.*)") if link then display = "[[w:" .. link .. "|" .. display .. "]]" end end if not link then display = "[[Appendix:Glossary#" .. anchor_encode(glossary) .. "|" .. display .. "]]" end end end end return display end --[==[ Turn a canonicalized tag spec (which describes a single, possibly multipart tag) into the displayed form. The tag spec may be a string (a canonical-form tag); a list of canonical-form tags (in the case of a simple multipart tag); or a list of mixed canonical-form tags and lists of such tags (in the case of a two-level multipart tag). `joiner` indicates how to join the parts of a multipart tag, and can be either {"and"} ("foo and bar", or "foo, bar and baz" for 3 or more), {"slash"} ("foo/bar"), {"en-dash"} ("foo–bar") or {nil}, which uses the global default found in {multipart_join_strategy()} in [[Module:form of/functions]]. (NOTE: The global default is {"slash"} and this seems unlikely to change.) A truthy `nolink` suppresses linking.]==] function export.get_tag_display_form(tagspec, lang, joiner, nolink) if type(tagspec) == "string" then return get_single_tag_display_form(tagspec, lang, nolink) end -- We have a multipart tag. See if there's a display handler to display them specially. for _, handler in ipairs(display_handlers or get_display_handlers()) do local displayval = handler(tagspec, joiner) if displayval then if nolink then displayval = remove_links(displayval) end return displayval end end -- No display handler. local displayed_tags = {} for _, first_level_tag in ipairs(tagspec) do if type(first_level_tag) == "string" then insert(displayed_tags, get_single_tag_display_form(first_level_tag, lang, nolink)) else -- A first-level element of a two-level multipart tag. Currently we just separate the individual components -- with spaces, but other ways are possible, e.g. using an underscore, colon, parens or braces. local components = {} for _, component in ipairs(first_level_tag) do insert(components, get_single_tag_display_form(component, lang, nolink)) end insert(displayed_tags, concat(components, " ")) end end return join_multiparts(displayed_tags, joiner) end get_tag_display_form = export.get_tag_display_form --[==[ Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are represented as lists, and two-level multipart tags as lists of lists), convert to displayed form (a string). See {get_tag_display_form()} for the meaning of `joiner`. A truthy `nolink` suppresses linking.]==] function export.get_tag_set_display_form(normalized_tag_set, lang, joiner, nolink) local parts = {} for _, tagspec in ipairs(normalized_tag_set) do local to_insert = get_tag_display_form(tagspec, lang, joiner, nolink) -- Maybe insert a space before inserting the display form of the tag. We insert a space if -- (a) we're not the first tag; and -- (b) the tag we're about to insert doesn't have the "no_space_on_left" property; and -- (c) the preceding tag doesn't have the "no_space_on_right" property. -- NOTE: We depend here on the fact that -- (1) all tags with either of the above properties set have the same display form as canonical form, and -- (2) all tags with either of the above properties set are single-character tags. -- The second property is an optimization to avoid looking up display forms resulting from multipart tags, -- which won't be found and which will trigger loading of [[Module:form of/data/2]]. If multichar punctuation is -- added in the future, it's ok to change the == 1 below to <= 2 or <= 3. -- -- If the first property above fails to hold in the future, we need to track the canonical form of each tag -- (including the previous one) as well as the display form. This would also avoid the need for the == 1 check. if #parts > 0 then local most_recent_tagobj = parts[#parts]:match("^.[\128-\191]*$") and lookup_tag(parts[#parts], lang) local to_insert_tagobj = to_insert:match("^.[\128-\191]*$") and lookup_tag(to_insert, lang) if ( (not most_recent_tagobj or not most_recent_tagobj.no_space_on_right) and (not to_insert_tagobj or not to_insert_tagobj.no_space_on_left) ) then insert(parts, " ") end end insert(parts, to_insert) end return concat(parts) end get_tag_set_display_form = export.get_tag_set_display_form --[==[ Split a tag set containing two-level multipart tags into one or more tag sets not containing such tags. Single-level multipart tags are left alone. (If we need to, a slight modification of the following code will also split single-level multipart tags.) This assumes that multipart tags are represented as lists and two-level multipart tags are represented as lists of lists, as is output by {normalize_tag_set()}. NOTE: We have to be careful to properly handle imbalanced two-level multipart tags such as `def:s//p` (or the reverse, `s//def:p`).]==] local function split_two_level_multipart_tag_set(tag_set) for i, tag in ipairs(tag_set) do if type(tag) == "table" then -- We saw a multipart tag. Check if any of the parts are two-level. local saw_two_level_tag = false for _, first_level_tag in ipairs(tag) do if type(first_level_tag) == "table" then saw_two_level_tag = true break end end if saw_two_level_tag then -- We found a two-level multipart tag. -- (1) Extract the preceding tags. local pre_tags = slice(tag_set, 1, i - 1) -- (2) Extract the following tags. local post_tags = slice(tag_set, i + 1) -- (3) Loop over each tag set alternant in the two-level multipart tag. -- For each alternant, form the tag set consisting of pre_tags + alternant + post_tags, -- and recursively split that tag set. local resulting_tag_sets = {} for _, first_level_tag_set in ipairs(tag) do local expanded_tag_set = {} extend(expanded_tag_set, pre_tags) -- The second level may have a string or a list. if type(first_level_tag_set) == "table" then extend(expanded_tag_set, first_level_tag_set) else insert(expanded_tag_set, first_level_tag_set) end extend(expanded_tag_set, post_tags) extend(resulting_tag_sets, split_two_level_multipart_tag_set(expanded_tag_set)) end return resulting_tag_sets end end end return {tag_set} end local function try_lang_specific_module(langcode, modules_tried, name, data) local lang_specific_module = form_of_lang_data_module_prefix .. langcode .. "/functions" local langdata = safe_require(lang_specific_module) if langdata then insert(modules_tried, lang_specific_module) if langdata.cat_functions then local fn = langdata.cat_functions[name] if fn then return fn(data), true end end end return nil, false end -- Call a named function, either from the lang-specific data in -- [[Module:form of/lang-specific/LANGCODE/functions]] or in [[Module:form of/functions]]. local function call_named_function(name, funtype, normalized_tag_set, lang, POS, pagename, lemmas) local data = { pagename = pagename or default_pagename or get_default_pagename(), lemmas = lemmas, tag_set = normalized_tag_set, lang = lang, POS = POS } local modules_tried = {} -- First try lang-specific. while lang do local retval, found_it = try_lang_specific_module(lang:getCode(), modules_tried, name, data) if found_it then return retval end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end -- Try lang-independent. insert(modules_tried, form_of_functions_module) local fn = (cat_functions or get_cat_functions())[name] if fn then return fn(data) end for i, modname in ipairs(modules_tried) do modules_tried[i] = "[[" .. modname .. "]]" end error(("No %s function named '%s' in %s"):format(funtype, name, list_to_text(modules_tried, nil, " or "))) end -- Given a tag from the current tag set (which may be a list in case of a multipart tag), -- and a tag from a categorization spec, check that the two match. -- (1) If both are strings, we just check for equality. -- (2) If the spec tag is a string and the tag set tag is a list (i.e. it originates from a -- multipart tag), we check that the spec tag is in the list. This is because we want to treat -- multipart tags in user-specified tag sets as if the user had specified multiple tag sets. -- For example, if the user said "1//3|s|pres|ind" and the categorization spec says {"has", "1"}, -- we want this to match, because "1//3|s|pres|ind" should be treated equivalently to two tag -- sets "1|s|pres|ind" and "3|s|pres|ind", and the former matches the categorization spec. -- (3) If the spec tag is a list (i.e. it originates from a multipart tag), we check that the -- tag set tag is also a list and is a superset of the spec tag. For example, if the categorization -- spec says {"has", "1//3"}, then the tag set tag must be a multipart tag that has both "1" and "3" -- in it. "1//3" works, as does "1//2//3". local function tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) if type(spec_tag) == "table" then if type(tag_set_tag) == "table" and is_subset_list(spec_tag, tag_set_tag) then return true end elseif type(tag_set_tag) == "table" then if contains(tag_set_tag, spec_tag) then return true end elseif tag_set_tag == spec_tag then return true end return false end -- Check that the current tag set matches the given spec tag. This means that any of the tags -- in the current tag set match, according to tag_set_tag_matches_spec_tag(); see above. If the -- current tag set contains only string tags (i.e. no multipart tags), and the spec tag is a -- string (i.e. not a multipart tag), this boils down to list containment, but it gets more -- complex when multipart tags are present. local function tag_set_matches_spec_tag(spec_tag, tag_set, lang) spec_tag = normalize_tag(spec_tag, lang) for _, tag_set_tag in ipairs(tag_set) do if tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) then return true end end return false end -- Check whether the given spec matches the current tag set. Two values are returned: -- (1) whether the spec matches the tag set; (2) the index of the category to add if -- the spec matches. local function check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if type(spec) == "boolean" then return spec elseif type(spec) ~= "table" then error("Wrong type of condition " .. spec .. ": " .. type(spec)) end local predicate = spec[1] if predicate == "has" then return tag_set_matches_spec_tag(spec[2], tag_set, lang), 3 elseif predicate == "hasall" then for _, tag in ipairs(spec[2]) do if not tag_set_matches_spec_tag(tag, tag_set, lang) then return false, 3 end end return true, 3 elseif predicate == "hasany" then for _, tag in ipairs(spec[2]) do if tag_set_matches_spec_tag(tag, tag_set, lang) then return true, 3 end end return false, 3 elseif predicate == "tags=" then local normalized_spec_tag_sets = normalize_tag_set(spec[2], lang) if #normalized_spec_tag_sets > 1 then error("Internal error: No support for conjoined shortcuts in category/label specs in " .. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|")) end local normalized_spec_tag_set = normalized_spec_tag_sets[1] -- Check for and disallow two-level multipart tags in the specs. FIXME: Remove this when we remove -- support for two-level multipart tags. for _, tag in ipairs(normalized_spec_tag_set) do if type(tag) == "table" then for _, subtag in ipairs(tag) do if type(subtag) == "table" then error("Internal error: No support for two-level multipart tags in category/label specs" .. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|")) end end end end -- Allow tags to be in different orders, and multipart tags to be in different orders. To handle this, -- we first check that both tag set tags and spec tags have the same length. If so, we sort the -- multipart tags in the tag set tags and spec tags, and then check that all tags in the spec tags are -- in the tag set tags. if #tag_set ~= #normalized_spec_tag_set then return false, 3 end local tag_set_tags = deep_copy(tag_set) for i=1,#tag_set_tags do if type(tag_set_tags[i]) == "table" then sort(tag_set_tags[i]) end if type(normalized_spec_tag_set[i]) == "table" then sort(normalized_spec_tag_set[i]) end end for i=1,#tag_set_tags do if not contains(tag_set_tags, normalized_spec_tag_set[i]) then return false, 3 end end return true, 3 elseif predicate == "p=" then return POS == normalize_pos(spec[2]), 3 elseif predicate == "pany" then for _, specpos in ipairs(spec[2]) do if POS == normalize_pos(specpos) then return true, 3 end end return false, 3 elseif predicate == "pexists" then return POS ~= nil, 2 elseif predicate == "not" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) return not condval, 3 elseif predicate == "and" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if condval then condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) end return condval, 4 elseif predicate == "or" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if not condval then condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) end return condval, 4 elseif predicate == "call" then return call_named_function(spec[2], "condition", normalized_tag_set, lang, POS, pagename, lemmas), 3 else error("Unrecognized predicate: " .. predicate) end end -- Process a given spec. This checks any conditions in the spec against the -- tag set, and insert any resulting categories into `categories`. Return value -- is true if the outermost condition evaluated to true and a category was inserted -- (this is used in {"cond" ...} conditions, which stop when a subcondition evaluates -- to true). local function process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) if not spec then return false elseif type(spec) == "string" then -- A category. Substitute POS request with user-specified part of speech or default. spec = spec:gsub("<<p=(.-)>>", function(default) return POS or normalize_pos(default) end) insert(categories, lang:getFullName() .. " " .. spec) return true elseif type(spec) == "table" and spec.labels then -- A label spec. for _, label in ipairs(spec.labels) do insert_if_not(labels, label) end return true elseif type(spec) ~= "table" then error("Wrong type of specification " .. spec .. ": " .. type(spec)) end local predicate = spec[1] if predicate == "multi" then for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2. process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end return true elseif predicate == "cond" then for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2. if process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) then return true end end return false elseif predicate == "call" then return process_spec( call_named_function(spec[2], "spec", normalized_tag_set, lang, POS, pagename, lemmas), tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels ) else local condval, ifspec = check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if condval then process_spec(spec[ifspec], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) return true else process_spec(spec[ifspec + 1], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) -- FIXME: Are we sure this is correct? return false end end end --[==[ Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are represented as lists, and two-level multipart tags as lists of lists), fetch the associated categories and labels. Return two values, a list of categories and a list of labels. `lang` is the language of term represented by the tag set, and `POS` is the user-provided part of speech (which may be {nil}).]==] function export.fetch_categories_and_labels(normalized_tag_set, lang, POS, pagename, lemmas) local categories, labels = {}, {} POS = normalize_pos(POS) -- First split any two-level multipart tags into multiple sets, to make our life easier. for _, tag_set in ipairs(split_two_level_multipart_tag_set(normalized_tag_set)) do local langcode = lang:getCode() local langspecs = (m_cats_data or get_m_cats_data())[langcode] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end local full_code = lang:getFullCode() if full_code ~= langcode then local langspecs = (m_cats_data or get_m_cats_data())[full_code] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end end if full_code ~= "und" then local langspecs = (m_cats_data or get_m_cats_data())["und"] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end end end return categories, labels end fetch_categories_and_labels = export.fetch_categories_and_labels local function format_labels(labels, data, notext) if labels and #labels > 0 then return show_labels{ labels = labels, lang = data.lang, sort = data.sort, nocat = data.nocat } .. (notext and (data.pretext or "") == "" and "" or " ") else return "" end end --[==[ Implementation of templates that display inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with the following fields: * `.lang`: ('''''required''''') Language to use when looking up language-specific inflection tags, categories and labels, and for displaying categories and labels. * `.tags`: ('''''required''' unless `.tag_sets` is given'') List of non-canonicalized inflection tags. Multiple tag sets can be indicated by a {";"} as one of the tags, and tag-set properties may be attached to the last tag of a tag set. The tags themselves may come directly from the user (as in {{tl|inflection of}}); come partly from the user (as in {{tl|participle of}}, which adds the tag `part` to user-specified inflection tags); or be entirely specified by the template (as in {{tl|past participle of}}). * `.tag_sets`: ('''''required''' unless `.tags` is given'') List of non-canonicalized tag sets and associated per-tag-set properties. Each element of the list is an object of the form { {tags = {"TAG", "TAG", ...}, labels = {"LABEL", "LABEL", ...}}. If `.tag_sets` is specified, `.tags` should not be given and vice-versa. Specifying `.tag_sets` in place of tags allowed per-tag set labels to be specified; otherwise, there is no advantage. [[Module:pt-gl-inflections]] uses this functionality to supply labels like {"Brazil"} and {"Portugal"} associated with specific tag sets. * `.lemmas`: ('''''recommended''''') List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly. If omitted entirely, no lemma links are shown and the connecting "of" is also omitted. * `.lemma_face`: ('''''recommended''''') "Face" to use when displaying the lemma objects. Usually should be set to {"term"}. * `.POS`: ('''''recommended''''') Categorizing part-of-speech tag. Comes from the {{para|p}} or {{para|POS}} argument of {{tl|inflection of}}. * `.pagename`: Page name of "current" page or nil to use the actual page title; for testing purposes. * `.conj`: Conjunction or separator to use when joining multiple lemma objects. Defaults to {"and"}. * `.enclitics`: List of enclitics to display after the lemmas, in parens. * `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}. * `.no_format_categories`: If true, don't format the categories derived from the inflection tags; just return them. * `.sort`: Sort key for formatted categories. Ignored when `.no_format_categories` = {true}. * `.nocat`: Suppress computation of categories (even if `.no_format_categories` is not given). * `.notext`: Disable display of all tag text and `inflection of` text. (FIXME: Maybe not implemented correctly.) * `.nolink`: Suppress linking of terms in inflection tags. * `.capfirst`: Capitalize the first word displayed. * `.pretext`: Additional text to display before the inflection tags, but after any top-level labels. * `.posttext`: Additional text to display after the lemma links. * `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is {"form-of-definition use-with-mention"}. * `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}. * `.joiner`: Override the joiner (normally a slash) used to join multipart tags. You should normally not specify this. * `.nowrap`: Do not wrap the form-of definitions in a span, unless `.text_classes` is specified. * `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified in-place to save memory; otherwise they will be copied before modifying. A typical call might look like this (for {{m+|es|amo}}): { local lang = require("Module:languages").getByCode("es") local lemma_obj = { lang = lang, term = "amar", } return m_form_of.tagged_inflections({ lang = lang, tags = {"1", "s", "pres", "ind"}, lemmas = {lemma_obj}, lemma_face = "term", POS = "verb" }) } Normally, one value is returned, the formatted text, which has appended to it the formatted categories derived from the tag-set-related categories generated by the specs in [Module:form of/cats]]. To suppress this, set `data.no_format_categories` = {true}, in which case two values are returned, the formatted text without any formatted categories appended and a list of the categories to be formatted. NOTE: There are two sets of categories that may be generated: (1) categories derived directly from the tag sets, as specified in [[Module:form of/cats]]; (2) categories derived from tag-set labels, either (a) set explicitly by the caller in `data.tag_sets`, (b) specified by the user using `<lb:...>` attached to the last tag in a tag set, or (c) specified in [[Module:form of/cats]]. The second type (label-related categories) are currently not returned in the second return value of {tagged_inflections()}, and are currently inserted into the output text even if `data.no_format_categories` is set to {true}; but they can be suppressed by setting `data.nocat` = {true} (which also suppresses the first type of categories, those derived directly from tag sets, even if `data.no_format_categories` is set to {true}).]==] function export.tagged_inflections(data) if not data.tags and not data.tag_sets then error("First argument must be a table of arguments, and `.tags` or `.tag_sets` must be specified") end if data.tags and data.tag_sets then error("Both `.tags` and `.tag_sets` cannot be specified") end local tag_sets = data.tag_sets if not tag_sets then tag_sets = split_tag_set(data.tags) for i, tag_set in ipairs(tag_sets) do tag_sets[i] = parse_tag_set_properties(tag_set) end end local inflections = {} local categories = {} for _, tag_set in ipairs(tag_sets) do local normalized_tag_sets = normalize_tag_set(tag_set.tags, data.lang, "do-track") for _, normalized_tag_set in ipairs(normalized_tag_sets) do local this_categories, this_labels = fetch_categories_and_labels(normalized_tag_set, data.lang, data.POS, data.pagename, type(data.lemmas) == "table" and data.lemmas or nil) if not data.nocat then extend(categories, this_categories) end local cur_infl = get_tag_set_display_form(normalized_tag_set, data.lang, data.joiner, data.nolink) if #cur_infl > 0 then if tag_set.labels then this_labels = append(tag_set.labels, this_labels) end insert(inflections, {infl_text = cur_infl, labels = this_labels}) end end end local overall_labels, need_per_tag_set_labels for _, inflection in ipairs(inflections) do if overall_labels == nil then overall_labels = inflection.labels elseif not deep_equals(overall_labels, inflection.labels) then need_per_tag_set_labels = true overall_labels = nil break end end if not need_per_tag_set_labels then for _, inflection in ipairs(inflections) do inflection.labels = nil end end local format_data = shallow_copy(data) local of_text = data.lemmas and " of" or "" local formatted_text, this_categories if #inflections == 1 then if need_per_tag_set_labels then error("Internal error: need_per_tag_set_labels should not be set with one inflection") end format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or ((data.capfirst and ucfirst(inflections[1].infl_text) or inflections[1].infl_text) .. of_text)) formatted_text, this_categories = format_form_of(format_data) else format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or ((data.capfirst and "Inflection" or "inflection") .. of_text)) format_data.posttext = (data.posttext or "") .. ":" local link link, this_categories = format_form_of(format_data) local text_classes = data.text_classes if text_classes == nil and not data.nowrap then text_classes = "form-of-definition use-with-mention" end for i, inflection in ipairs(inflections) do inflections[i] = "\n## " .. format_labels(inflection.labels, data, false) .. wrap_in_span(inflection.infl_text, text_classes) end formatted_text = link .. concat(inflections) end if this_categories[1] then extend(categories, this_categories) end if not data.no_format_categories then if categories[1] then formatted_text = formatted_text .. format_categories(categories, data.lang, data.sort, nil, export.force_cat) end return formatted_text end return formatted_text, categories end function export.dump_form_of_data(_frame) local data = { require(form_of_data1_module), require(form_of_data2_module) } return require(json_module).toJSON(data) end export.form_of_cats_module = form_of_cats_module export.form_of_data1_module = form_of_data1_module export.form_of_data2_module = form_of_data2_module export.form_of_functions_module = form_of_functions_module export.form_of_lang_data_module_prefix = form_of_lang_data_module_prefix export.headword_data_module = headword_data_module -- so all form-of modules stay in sync return export 537y0z5vf78rgvzdvy0emj66k9afncd 238979 238978 2026-11-14T03:01:04Z Lee 19 පැරණි සංස්කරණයකින් ගත් කොටස්... 238979 Scribunto text/plain local m_sinhala = require("Module:sinhala") local export = {} export.force_cat = false -- for testing; set to true to display categories even on non-mainspace pages local debug_track_module = "Module:debug/track" local etymology_module = "Module:etymology" local form_of_cats_module = "Module:form of/cats" local form_of_data_module = "Module:form of/data" local form_of_data1_module = "Module:form of/data/1" local form_of_data2_module = "Module:form of/data/2" local form_of_functions_module = "Module:form of/functions" local form_of_lang_data_module_prefix = "Module:form of/lang-data/" local function_module = "Module:fun" local headword_data_module = "Module:headword/data" local json_module = "Module:JSON" local labels_module = "Module:labels" local links_module = "Module:links" local load_module = "Module:load" local parse_utilities_module = "Module:parse utilities" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local table_deep_equals_module = "Module:table/deepEquals" local utilities_module = "Module:utilities" local anchor_encode = mw.uri.anchorEncode local concat = table.concat local dump = mw.dumpObject local fetch_categories_and_labels -- Defined below. local format_form_of -- Defined below. local get_tag_display_form -- Defined below. local get_tag_set_display_form -- Defined below. local insert = table.insert local ipairs = ipairs local is_link_or_html -- Defined below. local list_to_text = mw.text.listToText local lookup_shortcut -- Defined below. local lookup_tag -- Defined below. local normalize_tag_set -- Defined below. local parse_tag_set_properties -- Defined below. local require = require local sort = table.sort local split_tag_set -- Defined below. local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function append(...) append = require(table_module).append return append(...) end local function contains(...) contains = require(table_module).contains return contains(...) end local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) end local function deep_equals(...) deep_equals = require(table_deep_equals_module) return deep_equals(...) end local function extend(...) extend = require(table_module).extend return extend(...) end local function format_categories(...) format_categories = require(utilities_module).format_categories return format_categories(...) end local function full_link(...) full_link = require(links_module).full_link return full_link(...) end local function insert_if_not(...) insert_if_not = require(table_module).insertIfNot return insert_if_not(...) end local function is_subset_list(...) is_subset_list = require(table_module).isSubsetList return is_subset_list(...) end local function iterate_from(...) iterate_from = require(function_module).iterateFrom return iterate_from(...) end local function join_multiparts(...) join_multiparts = require(form_of_functions_module).join_multiparts return join_multiparts(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function parse_inline_modifiers(...) parse_inline_modifiers = require(parse_utilities_module).parse_inline_modifiers return parse_inline_modifiers(...) end local function remove_links(...) remove_links = require(links_module).remove_links return remove_links(...) end local function safe_load_data(...) safe_load_data = require(load_module).safe_load_data return safe_load_data(...) end local function safe_require(...) safe_require = require(load_module).safe_require return safe_require(...) end local function serial_comma_join(...) serial_comma_join = require(table_module).serialCommaJoin return serial_comma_join(...) end local function shallow_copy(...) shallow_copy = require(table_module).shallowCopy return shallow_copy(...) end local function show_labels(...) show_labels = require(labels_module).show_labels return show_labels(...) end local function slice(...) slice = require(table_module).slice return slice(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function ucfirst(...) ucfirst = require(string_utilities_module).ucfirst return ucfirst(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local cat_functions local function get_cat_functions() cat_functions, get_cat_functions = require(form_of_functions_module).cat_functions, nil return cat_functions end local default_pagename local function get_default_pagename() default_pagename, get_default_pagename = load_data(headword_data_module).pagename, nil return default_pagename end local display_handlers local function get_display_handlers() display_handlers, get_display_handlers = require(form_of_functions_module).display_handlers, nil return display_handlers end local m_cats_data local function get_m_cats_data() m_cats_data, get_m_cats_data = load_data(form_of_cats_module), nil return m_cats_data end local m_data local function get_m_data() -- Needs require. m_data, get_m_data = require(form_of_data_module), nil return m_data end local m_data1 local function get_m_data1() m_data1, get_m_data1 = load_data(form_of_data1_module), nil return m_data1 end local m_data2 local function get_m_data2() m_data2, get_m_data2 = load_data(form_of_data2_module), nil return m_data2 end local m_pos_data local function get_m_pos_data() m_pos_data, get_m_pos_data = load_data(headword_data_module).pos_aliases, nil return m_pos_data end --[==[ intro: This module implements the underlying processing of {{tl|form of}}, {{tl|inflection of}} and specific variants such as {{tl|past participle of}} and {{tl|alternative spelling of}}. Most of the logic in this file is to handle tags in {{tl|inflection of}}. Other related files: * [[Module:form of/templates]] contains the majority of the logic that implements the templates themselves. * [[Module:form of/data/1]] is a data-only file containing information on the more common inflection tags, listing the tags, their shortcuts, the category they belong to (tense-aspect, case, gender, voice-valence, etc.), the appropriate glossary link and the wikidata ID. * [[Module:form of/data/2]] is a data-only file containing information on the less common inflection tags, in the same format as [[Module:form of/data/1]]. * [[Module:form of/lang-data/LANGCODE]] is a data-only file containing information on the language-specific inflection tags for the language with code LANGCODE, in the same format as [[Module:form of/data/1]]. Language-specific tags override general tags. * [[Module:form of/cats]] is a data-only file listing the language-specific categories that are added when the appropriate combinations of tags are seen for a given language. * [[Module:form of/functions]] contains functions for use with [[Module:form of/data/1]] and [[Module:form of/cats]]. They are contained in this module because data-only modules can't contain code. The functions in this file are of two types: *# Display handlers allow for customization of the display of multipart tags (see below). Currently there is only one such handler, for handling multipart person tags such as `1//2//3`. *# Cat functions allow for more complex categorization logic, and are referred to by name in [[Module:form of/cats]]. Currently no such functions exist. The following terminology is used in conjunction with {{tl|inflection of}}: * A ''tag'' is a single grammatical item, as specified in a single numbered parameter of {{tl|inflection of}}. Examples are `masculine`, `nominative`, or `first-person`. Tags may be abbreviated, e.g. `m` for `masculine`, `nom` for `nominative`, or `1` for `first-person`. Such abbreviations are called ''aliases'', and some tags have multiple equivalent aliases (e.g. `p` or `pl` for `plural`). The full, non-abbreviated form of a tag is called its ''canonical form''. * The ''display form'' of a tag is the way it's displayed to the user. Usually the displayed text of the tag is the same as its canonical form, and it normally functions as a link to a glossary entry explaining the tag. Usually the link is to an entry in [[Appendix:Glossary]], but sometimes the tag is linked to an individual dictionary entry or to a Wikipedia entry. Occasionally, the display text differs from the canonical form of the tag. An example is the tag `comparative case`, which has the display text read as simply `comparative`. Normally, tags referring to cases don't have the word "case" in them, but in this case the tag `comparative` was already used as an alias for the tag `comparative degree`, so the tag was named `comparative case` to avoid clashing. A similar situation occurs with `adverbial case` vs. the grammar tag `adverbial` (as in `adverbial participle`). * A ''tag set'' is an ordered list of tags, which together express a single inflection, for example, `1|s|pres|ind`, which can be expanded to canonical-form tags as `first-person|singular|present|indicative`. * A ''conjoined tag set'' is a tag set that consists of multiple individual tag sets separated by a semicolon, e.g. `1|s|pres|ind|;|2|s|imp`, which specifies two tag sets, `1|s|pres|ind` as above and `2|s|imp` (in canonical form, `second-person|singular|imperative`). Multiple tag sets specified in a single call to {{tl|inflection of}} are specified in this fashion. Conjoined tag sets can also occur in list-tag shortcuts. * A ''multipart tag'' is a tag that embeds multiple tags within it, such as `f//n` or `nom//acc//voc`. These are used in the case of [[syncretism]], when the same form applies to multiple inflections. Examples are the Spanish present subjunctive, where the first-person and third-person singular have the same form (e.g. {{m|es|siga}} from {{m|es|seguir|t=to follow}}), or Latin third-declension adjectives, where the dative and ablative plural of all genders have the same form (e.g. {{m|la|omnibus}} from {{m|la|omnis|t=all}}). These would be expressed respectively as `1//3|s|pres|sub` and `dat//abl|m//f//n|p`, where the use of the multipart tag compactly encodes the syncretism and avoids the need to individually list out all of the inflections. Multipart tags currently display as a list separated by a slash, e.g. ''dative/ablative'' or ''masculine/feminine/neuter'' where each individual word is linked appropriately. As a special case, multipart tags involving persons display specially; for example, the multipart tag `1//2//3` displays as ''first-, second- and third-person'', with the word "person" occurring only once. * A ''two-level multipart tag'' is a special type of multipart tag that joins two or more tag sets instead of joining individual tags. The tags within the tag set are joined by a colon, e.g. `1:s//3:p`, which is displayed as ''first-person singular and third-person plural'', e.g. for use with the form {{m|grc|μέλλον}} of the verb {{m|grc|μέλλω|t=to intend}}, which uses the tag set `1:s//3:p|impf|actv|indc|unaugmented` to express the syncretism between the first singular and third plural forms of the imperfect active indicative unaugmented conjugation. Two-level multipart tags should be used sparingly; if in doubt, list out the inflections separately. [FIXME: Make two-level multipart tags obsolete.] * A ''shortcut'' is a tag that expands to any type of tag described above, or to any type of tag set described above. Aliases are a particular type of shortcut whose expansion is a single non-multipart tag. * A ''multipart shortcut'' is a shortcut that expands into a multipart tag, for example `123`, which expands to the multipart tag `1//2//3`. Only the most common such combinations exist as shortcuts. * A ''list shortcut'' is a special type of shortcut that expands to a list of tags instead of a single tag. For example, the shortcut `1s` expands to `1|s` (first-person singular). Only the most common such combinations exist as shortcuts. * A ''conjoined shortcut'' is a special type of list shortcut that consists of a conjoined tag set (multiple logical tag sets). For example, the English language-specific shortcut `ed-form` expands to `spast|;|past|part`, expressing the common syncretism between simple past and past participle in English (and in this case, `spast` is itself a list shortcut that expands to `simple|past`).]==] -- Add tracking category for PAGE when called from {{inflection of}} or -- similar TEMPLATE. The tracking category linked to is -- [[Wiktionary:Tracking/inflection of/PAGE]]. local function track(page) debug_track("inflection of/" .. -- avoid including links in pages (may cause error) page:gsub("%[", "("):gsub("%]", ")"):gsub("|", "!") ) end local function wrap_in_span(text, classes) if classes then return ("<span class='%s'>%s</span>"):format(classes, text) else return text end end local function show_linked_term(data) local termobj, face, span_classes, ok_to_destructively_modify, overall_lang, text_classes = data.termobj, data.face, data.span_classes, data.ok_to_destructively_modify, data.overall_lang, data.text_classes local need_to_copy, pretext_lang local categories = {} if overall_lang and overall_lang:getCode() ~= termobj.lang:getCode() then local lang_display lang_display, categories = require(etymology_module).insert_source_cat_get_display { lang = data.overall_lang, source = termobj.lang, } pretext_lang = wrap_in_span(lang_display .. " ", text_classes) end local has_decoration = termobj.q or termobj.qq or termobj.a or termobj.aa or termobj.l or termobj.ll or termobj.refs -- `show_decorations` is set by parse_{term,list}_with_inline_modifiers_and_separate_params in -- [[Module:parameter utilities]], called in [[Module:form of/templates]], so in most circumstances -- it's already set and we don't need to do a shallow-copy to set it. local need_to_set_show_decorations = has_decoration and not termobj.show_decorations need_to_copy = not ok_to_destructively_modify and (pretext_lang or need_to_set_show_decorations) if need_to_copy then termobj = shallow_copy(termobj) end if pretext_lang then termobj.pretext = pretext_lang end if need_to_set_show_decorations then termobj.show_decorations = true end return wrap_in_span(full_link(termobj, face), span_classes), categories end --[==[ Lowest-level implementation of form-of templates, including the general {{tl|form of}} as well as those that deal with inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with the following fields: * `.lang`: Overall language of the form-of template. If specified, any lemmas, enclitics or base lemmas that are of a different language will have that language displayed before the term in question. * `.text`: Text to insert before the lemmas. Wrapped in the value of `.text_classes`, or its default; see below. * `.lemmas`: List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly, or omitted, to show no lemma links and omit the connecting text. * `.lemma_face`: "Face" to use when displaying the lemma objects. Usually should be set to {"term"}. * `.conj`: Conjunction or separator to use when joining multiple lemma objects. If {nil}, defaults to {"and"}. If this has the value {false}, the lemmas are preceded with the `.separator` field in each lemma. * `.enclitics`: List of enclitics to display after the lemmas, in parens. * `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}. * `.base_lemmas`: List of base lemmas to display after the lemmas, in the case where the lemmas in `.lemmas` are themselves forms of another lemma (the base lemma), e.g. a comparative, superlative or participle. Each object is of the form { { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, conj = "CONJ" }} where PARAM_OBJ describes the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas); LEMMA_OBJ is an object suitable to be passed to {full_link()} in [[Module:links]]; and CONJ is the conjunction to join multiple lemmas with, defaulting to {"and"}. PARAM_OBJ is of the format { { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{tl|inflection of}} etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as { {"comd"}} or { {"past", "part"}}. * `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is {"form-of-definition use-with-mention"}. Use `false` for no wrapping. * `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}. Use `false` for no wrapping. * `.posttext`: Additional text to display after the lemma links. * `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified in-place to save memory; otherwise they will be copied before modifying. Returns two values, the formatted string and any categories to add the page to (which will arise if `.lang` is specified and a language other than `.lang` is given in one of the lemmas in `.lemmas` or enclitics in `.enclitics`). ]==] function export.format_form_of(data) if type(data) ~= "table" then error("Internal error: First argument must now be a table of arguments") end local text_classes = data.text_classes if text_classes == nil and not data.nowrap then text_classes = "form-of-definition use-with-mention" end local lemma_classes = data.lemma_classes if lemma_classes == nil then lemma_classes = "form-of-definition-link" end local parts = {} if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end -- insert(parts, data.text) -- if data.text ~= "" and data.lemmas then -- insert(parts, " ") -- end local categories = {} if data.lemmas then if type(data.lemmas) == "string" then insert(parts, wrap_in_span(data.lemmas, lemma_classes)) else local formatted_terms = {} for _, lemma in ipairs(data.lemmas) do local linked_term, this_categories = show_linked_term { termobj = lemma, face = data.lemma_face, span_classes = lemma_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, overall_lang = data.lang, text_classes = text_classes } if this_categories[1] then extend(categories, this_categories) end if data.conj == false and lemma.separator then insert(formatted_terms, lemma.separator) end insert(formatted_terms, linked_term) end if data.conj == false then insert(parts, concat(formatted_terms)) else insert(parts, serial_comma_join(formatted_terms, {conj = data.conj or "and"})) end end if data.lit then insert(parts, ", literally " .. require(links_module).mark(data.lit, "gloss")) end end if data.enclitics and #data.enclitics > 0 then -- The outer parens need to be outside of the text_classes span so they show in upright instead of italic, or -- they will clash with upright parens generated by link annotations such as transliterations and pos=. if text_classes then insert(parts, "</span>") end local formatted_terms = {} for _, enclitic in ipairs(data.enclitics) do -- FIXME, should we have separate clitic face and/or classes? local linked_term, this_categories = show_linked_term { termobj = enclitic, face = data.lemma_face, span_classes = lemma_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, overall_lang = data.lang, text_classes = text_classes } if this_categories[1] then extend(categories, this_categories) end insert(formatted_terms, linked_term) end insert(parts, " (") insert(parts, wrap_in_span("with enclitic" .. (#data.enclitics > 1 and "s" or "") .. " ", text_classes)) insert(parts, serial_comma_join(formatted_terms, {conj = data.enclitic_conj or "and"})) insert(parts, ")") if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end end if data.base_lemmas and #data.base_lemmas > 0 then for _, base_lemma in ipairs(data.base_lemmas) do insert(parts, ", the ") if text_classes then insert(parts, "</span>") end insert(parts, (export.tagged_inflections { lang = data.lang or base_lemma.lemmas[1].lang, tags = base_lemma.paramobj.tags, lemmas = base_lemma.lemmas, conj = base_lemma.conj or "and", lemma_face = data.lemma_face, no_format_categories = true, nocat = true, text_classes = data.text_classes, ok_to_destructively_modify = data.ok_to_destructively_modify, })) if text_classes then insert(parts, "<span class='" .. text_classes .. "'>") end end end -- FIXME, should posttext go before enclitics? If so we need to have separate handling for the -- final colon when there are multiple tag sets in tagged_inflections(). if data.posttext then insert(parts, data.posttext) end insert(parts, m_sinhala.sinhala(data.text)) if data.text ~= "" and data.lemmas then insert(parts, " ") end if text_classes then insert(parts, "</span>") end return concat(parts), categories end format_form_of = export.format_form_of --[==[ Return true if `tag` contains an internal link or HTML.]==] function export.is_link_or_html(tag) return tag:find("[[", nil, true) or tag:find("|", nil, true) or tag:find("<", nil, true) end is_link_or_html = export.is_link_or_html --[==[ Look up a tag (either a shortcut of any sort of a canonical long-form tag) and return its expansion. The expansion will be a string unless the shortcut is a list-tag shortcut such as `1s`; in that case, the expansion will be a list. The caller must handle both cases. Only one level of expansion happens; hence, `acc` expands to {"accusative"}, `1s` expands to { {"1", "s"}} (not to { {"first", "singular"}}) and `123` expands to {"1//2//3"}. The expansion will be the same as the passed-in tag in the following circumstances: # The tag is `;` (this is special-cased, and no lookup is done). # The tag is a multipart tag such as `nom//acc` (this is special-cased, and no lookup is done). # The tag contains a raw link (this is special-cased, and no lookup is done). # The tag contains HTML (this is special-cased, and no lookup is done). # The tag is already a canonical long-form tag. # The tag is unrecognized. This function first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in [[Module:form of/data/1]] (which includes more common non-lang-specific tags) and finally (only if the tag is not recognized as a shortcut or canonical tag, and is not of types 1-4 above) in [[Module:form of/data/2]]. If the expansion is a string and is different from the tag, track it if `do_track` is true.]==] function export.lookup_shortcut(tag, lang, do_track) -- If there is HTML or a link in the tag, return it directly; don't try -- to look it up, which will fail. if tag == ";" or tag:find("//", nil, true) or is_link_or_html(tag) then return tag end local expansion while lang do local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode()) -- If this is a canonical long-form tag, just return it, and don't check for shortcuts. This is an -- optimization; see below. if langdata then if langdata.tags[tag] then return tag end expansion = langdata.shortcuts[tag] if expansion then break end end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end if not expansion then -- If this is a canonical long-form tag, just return it, and don't check for shortcuts (which will cause -- [[Module:form of/data/2]] to be loaded, because there won't be a shortcut entry in [[Module:form of/data/1]] -- -- or, for that matter, in [[Module:form of/data/2]]). This is an optimization; the code will still work without -- it, but will use up more memory. if (m_data1 or get_m_data1()).tags[tag] then return tag end expansion = m_data1.shortcuts[tag] end if not expansion then expansion = (m_data2 or get_m_data2()).shortcuts[tag] end if not expansion then return tag end -- Maybe track the expansion if it's not the same as the raw tag. if do_track and expansion ~= tag and type(expansion) == "string" then track("tag/" .. tag) end return expansion end lookup_shortcut = export.lookup_shortcut --[==[ Look up a normalized/canonicalized tag and return the data object associated with it. If the tag isn't found, return nil. This first looks up in the lang-specific data module [[Module:form of/lang-data/LANGCODE]], then in [[Module:form of/data/1]] (which includes more common non-lang-specific tags) and then finally in [[Module:form of/data/2]].]==] function export.lookup_tag(tag, lang) while lang do local langdata = safe_load_data(form_of_lang_data_module_prefix .. lang:getCode()) local tag = langdata and langdata.tags[tag] if tag then return tag end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end local tagobj = (m_data1 or get_m_data1()).tags[tag] if tagobj then return tagobj end local tagobj2 = (m_data2 or get_m_data2()).tags[tag] if tagobj2 then return tagobj2 end return nil end lookup_tag = export.lookup_tag -- Normalize a single tag, which may be a shortcut but should not be a multipart tag, a multipart shortcut or a list -- shortcut. local function normalize_single_tag(tag, lang, do_track) local expansion = lookup_shortcut(tag, lang, do_track) if type(expansion) ~= "string" then error("Tag '" .. tag .. "' is a list shortcut, which is not allowed here") end tag = expansion if not lookup_tag(tag, lang) and do_track then -- If after all expansions and normalizations we don't recognize the canonical tag, track it. track("unknown") track("unknown/" .. tag) end return tag end --[=[ Normalize a component of a multipart tag. This should not have any // in it, but may join multiple individual tags with a colon, and may be a single list-tag shortcut, which is treated as if colon-separated. The return value may be a list of tags. ]=] local function normalize_multipart_component(tag, lang, do_track) -- If there is HTML or a link in the tag, don't try to split on colon. A colon may legitimately occur in either one, -- and we don't want these things parsed. Note that we don't do this check before splitting on //, which we don't -- expect to occur in links or HTML; see comment in normalize_tag(). if is_link_or_html(tag) then return tag end local components = split(tag, ":", true) if #components == 1 then -- We allow list-tag shortcuts inside of multipart tags, e.g. -- '1s//3p'. Check for this now. tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then -- Temporary tracking as we will disallow this. track("list-tag-inside-of-multipart") -- We found a list-tag shortcut; treat as if colon-separated. components = tag else return normalize_single_tag(tag, lang, do_track) end end local normtags = {} -- Temporary tracking as we will disallow this. track("two-level-multipart") for _, component in ipairs(components) do if do_track then -- There are multiple components; track each of the individual -- raw tags. track("tag/" .. component) end insert(normtags, normalize_single_tag(component, lang, do_track)) end return normtags end --[=[ Normalize a single tag. The return value may be a list (in the case of multipart tags), which will contain nested lists in the case of two-level multipart tags. ]=] local function normalize_tag(tag, lang, do_track) -- We don't check for links or HTML before splitting on //, which we don't expect to occur in links or HTML. Doing -- it this way allows for a tag like '{{lb|grc|Epic}}//{{lb|grc|Ionic}}' to function correctly (the template calls -- will be expanded before we process the tag, and will contain links and HTML). The only check we do is for a URL, -- which shouldn't normally occur, but might if the user tries to put an external link into the tag. URL's with // -- normally have the sequence ://, which should never normally occur when // and : are used in their normal ways. if tag:find("://", nil, true) then return tag end local split_tags = split(tag, "//", true) if #split_tags == 1 then local retval = normalize_multipart_component(tag, lang, do_track) if type(retval) == "table" then -- The user gave a tag like '1:s', i.e. with colon but without //. Allow this, but we need to return a -- nested list. return {retval} end return retval end local normtags = {} for _, single_tag in ipairs(split_tags) do if do_track then -- If the tag was a multipart tag, track each of individual raw tags. track("tag/" .. single_tag) end insert(normtags, normalize_multipart_component(single_tag, lang, do_track)) end return normtags end --[==[ Normalize a tag set (a list of tags) into its canonical-form tags. The return value is a list of normalized tag sets (a list because of there may be conjoined shortcuts among the input tags). A normalized tag set is a list of tag elements, where each element is either a string (the canonical form of a tag), a list of such strings (in the case of multipart tags) or a list of lists of such strings (in the case of two-level multipart tags). For example, the multipart tag `nom//acc//voc` will be represented in canonical form as { {"nominative", "accusative", "vocative"}}, and the two-level multipart tag `1:s//3:p` will be represented as { {{"first-person", "singular"}, {"third-person", "plural"}}}. Example 1: {normalize_tag_set({"nom//acc//voc", "n", "p"})} = { {{{"nominative", "accusative", "vocative"}, "masculine", "plural"}}} Example 2: {normalize_tag_set({"ed-form"}, ENGLISH)} = { {{"simple", "past"}, {"past", "participle"}}} Example 3: {normalize_tag_set({"archaic", "ed-form"}, ENGLISH)} = { {{"archaic", "simple", "past"}, {"archaic", "past", "participle"}}}]==] function export.normalize_tag_set(tag_set, lang, do_track) -- We track usage of shortcuts, normalized forms and (in the case of multipart tags or list tags) intermediate -- forms. For example, if the tags 1s|mn|gen|indefinite are passed in, we track the following: -- [[Wiktionary:Tracking/inflection of/tag/1s]] -- [[Wiktionary:Tracking/inflection of/tag/1]] -- [[Wiktionary:Tracking/inflection of/tag/s]] -- [[Wiktionary:Tracking/inflection of/tag/first-person]] -- [[Wiktionary:Tracking/inflection of/tag/singular]] -- [[Wiktionary:Tracking/inflection of/tag/mn]] -- [[Wiktionary:Tracking/inflection of/tag/m//n]] -- [[Wiktionary:Tracking/inflection of/tag/m]] -- [[Wiktionary:Tracking/inflection of/tag/n]] -- [[Wiktionary:Tracking/inflection of/tag/masculine]] -- [[Wiktionary:Tracking/inflection of/tag/neuter]] -- [[Wiktionary:Tracking/inflection of/tag/gen]] -- [[Wiktionary:Tracking/inflection of/tag/genitive]] -- [[Wiktionary:Tracking/inflection of/tag/indefinite]] local output_tag_set = {} local saw_semicolon = false for _, tag in ipairs(tag_set) do if do_track then -- Track the raw tag. track("tag/" .. tag) end -- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list -- of tags). tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then if contains(tag, ";") then -- If we saw a conjoined shortcut, we need to use a more general algorithm that can expand a single -- tag set into multiple. saw_semicolon = true break end for _, t in ipairs(tag) do if do_track then -- If the tag expands to a list of raw tags, track each of those. track("tag/" .. t) end insert(output_tag_set, normalize_tag(t, lang, do_track)) end else insert(output_tag_set, normalize_tag(tag, lang, do_track)) end end if not saw_semicolon then return {output_tag_set} end -- Use a more general algorithm that handles conjoined shortcuts. output_tag_set = {} for i, tag in ipairs(tag_set) do if do_track then -- Track the raw tag. track("tag/" .. tag) end -- Expand the tag, which may generate a new tag (either a fully canonicalized tag, a multipart tag, or a list -- of tags). tag = lookup_shortcut(tag, lang, do_track) if type(tag) == "table" then local output_tag_sets = {} local shortcut_tag_sets = split_tag_set(tag) local normalized_shortcut_tag_sets = {} for _, shortcut_tag_set in ipairs(shortcut_tag_sets) do extend(normalized_shortcut_tag_sets, normalize_tag_set(shortcut_tag_set, lang, do_track)) end local after_tags = slice(tag_set, i + 1) local normalized_after_tags_sets = normalize_tag_set(after_tags, lang, do_track) for _, normalized_shortcut_tag_set in ipairs(normalized_shortcut_tag_sets) do for _, normalized_after_tags_set in ipairs(normalized_after_tags_sets) do insert(output_tag_sets, append(output_tag_set, normalized_shortcut_tag_set, normalized_after_tags_set)) end end return output_tag_sets else insert(output_tag_set, normalize_tag(tag, lang, do_track)) end end error("Internal error: Should not get here") end normalize_tag_set = export.normalize_tag_set --[==[ Split a tag set that may consist of multiple semicolon-separated tag sets into the component tag sets.]==] function export.split_tag_set(tag_set) local split_tag_sets = {} local cur_tag_set = {} for _, tag in ipairs(tag_set) do if tag == ";" then if #cur_tag_set > 0 then insert(split_tag_sets, cur_tag_set) end cur_tag_set = {} else insert(cur_tag_set, tag) end end if #cur_tag_set > 0 then insert(split_tag_sets, cur_tag_set) end return split_tag_sets end split_tag_set = export.split_tag_set local tag_set_param_mods = { lb = { item_dest = "labels", convert = function(arg, _parse_err) return split(arg, "//", true) end, } } --[==[ Parse tag set properties from a tag set (list of tags). Currently no per-tag properties are recognized, and the only per-tag-set property recognized is `<lb:...>` for specifing label(s) for the tag set. Per-tag-set properties must be attached to the last tag.]==] function export.parse_tag_set_properties(tag_set) local function generate_tag_set_obj(last_tag) tag_set[#tag_set] = last_tag return {tags = tag_set} end local last_tag = tag_set[#tag_set] -- Check for inline modifier, e.g. מרים<tr:Miryem>. But exclude HTML entry with <span ...>, <i ...>, <br/> or -- similar in it, caused by wrapping an argument in {{l|...}}, {{af|...}} or similar. Basically, all tags of -- the sort we parse here should consist of a less-than sign, plus letters, plus a colon, e.g. <lb:...>, so if -- we see a tag on the outer level that isn't in this format, we don't try to parse it. The restriction to the -- outer level is to allow generated HTML inside of e.g. qualifier tags, such as foo<q:similar to {{m|fr|bar}}>. if last_tag:find("<", nil, true) and not last_tag:find("^[^<]*<%l*[^%l:]") then return parse_inline_modifiers(last_tag, { param_mods = tag_set_param_mods, generate_obj = generate_tag_set_obj, }) else return generate_tag_set_obj(last_tag) end end parse_tag_set_properties = export.parse_tag_set_properties local function normalize_pos(pos) if not pos then return nil end return (m_pos_data or get_m_pos_data())[pos] or pos end -- Return the display form of a single canonical-form tag. The value -- passed in must be a string (i.e. it cannot be a list describing a -- multipart tag). To handle multipart tags, use get_tag_display_form(). -- A truthy `nolink` suppresses linking. local function get_single_tag_display_form(normtag, lang, nolink) local data = lookup_tag(normtag, lang) local display = normtag -- If the tag has a special display form, use it if data and data.display then display = data.display if nolink then display = remove_links(display) end end -- If there is a nonempty glossary index, then show a link to it if not nolink then local glossary = data and data[(m_data or get_m_data()).GLOSSARY] if glossary ~= nil then if glossary == m_data.WIKT then display = "[[" .. normtag .. "|" .. display .. "]]" elseif glossary == m_data.WP then display = "[[w:" .. normtag .. "|" .. display .. "]]" elseif glossary == m_data.APPENDIX then display = "[[උපග්‍රන්ථය:ගැටපද විවරණය#" .. anchor_encode(normtag) .. "|" .. display .. "]]" elseif type(glossary) ~= "string" then error(("Internal error: Wrong type %s for glossary value %s for tag %s"):format( type(glossary), dump(glossary), normtag)) else local link = glossary:match("^wikt:(.*)") if link then display = "[[" .. link .. "|" .. display .. "]]" end if not link then link = glossary:match("^w:(.*)") if link then display = "[[w:" .. link .. "|" .. display .. "]]" end end if not link then display = "[[උපග්‍රන්ථය:ගැටපද විවරණය#" .. anchor_encode(m_sinhala.sinhala(glossary)) .. "|" .. m_sinhala.sinhala(display) .. "]]" end end end end return display end --[==[ Turn a canonicalized tag spec (which describes a single, possibly multipart tag) into the displayed form. The tag spec may be a string (a canonical-form tag); a list of canonical-form tags (in the case of a simple multipart tag); or a list of mixed canonical-form tags and lists of such tags (in the case of a two-level multipart tag). `joiner` indicates how to join the parts of a multipart tag, and can be either {"and"} ("foo and bar", or "foo, bar and baz" for 3 or more), {"slash"} ("foo/bar"), {"en-dash"} ("foo–bar") or {nil}, which uses the global default found in {multipart_join_strategy()} in [[Module:form of/functions]]. (NOTE: The global default is {"slash"} and this seems unlikely to change.) A truthy `nolink` suppresses linking.]==] function export.get_tag_display_form(tagspec, lang, joiner, nolink) if type(tagspec) == "string" then return get_single_tag_display_form(tagspec, lang, nolink) end -- We have a multipart tag. See if there's a display handler to display them specially. for _, handler in ipairs(display_handlers or get_display_handlers()) do local displayval = handler(tagspec, joiner) if displayval then if nolink then displayval = remove_links(displayval) end return displayval end end -- No display handler. local displayed_tags = {} for _, first_level_tag in ipairs(tagspec) do if type(first_level_tag) == "string" then insert(displayed_tags, get_single_tag_display_form(first_level_tag, lang, nolink)) else -- A first-level element of a two-level multipart tag. Currently we just separate the individual components -- with spaces, but other ways are possible, e.g. using an underscore, colon, parens or braces. local components = {} for _, component in ipairs(first_level_tag) do insert(components, get_single_tag_display_form(component, lang, nolink)) end insert(displayed_tags, concat(components, " ")) end end return join_multiparts(displayed_tags, joiner) end get_tag_display_form = export.get_tag_display_form --[==[ Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are represented as lists, and two-level multipart tags as lists of lists), convert to displayed form (a string). See {get_tag_display_form()} for the meaning of `joiner`. A truthy `nolink` suppresses linking.]==] function export.get_tag_set_display_form(normalized_tag_set, lang, joiner, nolink) local parts = {} for _, tagspec in ipairs(normalized_tag_set) do local to_insert = get_tag_display_form(tagspec, lang, joiner, nolink) -- Maybe insert a space before inserting the display form of the tag. We insert a space if -- (a) we're not the first tag; and -- (b) the tag we're about to insert doesn't have the "no_space_on_left" property; and -- (c) the preceding tag doesn't have the "no_space_on_right" property. -- NOTE: We depend here on the fact that -- (1) all tags with either of the above properties set have the same display form as canonical form, and -- (2) all tags with either of the above properties set are single-character tags. -- The second property is an optimization to avoid looking up display forms resulting from multipart tags, -- which won't be found and which will trigger loading of [[Module:form of/data/2]]. If multichar punctuation is -- added in the future, it's ok to change the == 1 below to <= 2 or <= 3. -- -- If the first property above fails to hold in the future, we need to track the canonical form of each tag -- (including the previous one) as well as the display form. This would also avoid the need for the == 1 check. if #parts > 0 then local most_recent_tagobj = parts[#parts]:match("^.[\128-\191]*$") and lookup_tag(parts[#parts], lang) local to_insert_tagobj = to_insert:match("^.[\128-\191]*$") and lookup_tag(to_insert, lang) if ( (not most_recent_tagobj or not most_recent_tagobj.no_space_on_right) and (not to_insert_tagobj or not to_insert_tagobj.no_space_on_left) ) then insert(parts, " ") end end insert(parts, to_insert) end return concat(parts) .. " පදය" end get_tag_set_display_form = export.get_tag_set_display_form --[==[ Split a tag set containing two-level multipart tags into one or more tag sets not containing such tags. Single-level multipart tags are left alone. (If we need to, a slight modification of the following code will also split single-level multipart tags.) This assumes that multipart tags are represented as lists and two-level multipart tags are represented as lists of lists, as is output by {normalize_tag_set()}. NOTE: We have to be careful to properly handle imbalanced two-level multipart tags such as `def:s//p` (or the reverse, `s//def:p`).]==] local function split_two_level_multipart_tag_set(tag_set) for i, tag in ipairs(tag_set) do if type(tag) == "table" then -- We saw a multipart tag. Check if any of the parts are two-level. local saw_two_level_tag = false for _, first_level_tag in ipairs(tag) do if type(first_level_tag) == "table" then saw_two_level_tag = true break end end if saw_two_level_tag then -- We found a two-level multipart tag. -- (1) Extract the preceding tags. local pre_tags = slice(tag_set, 1, i - 1) -- (2) Extract the following tags. local post_tags = slice(tag_set, i + 1) -- (3) Loop over each tag set alternant in the two-level multipart tag. -- For each alternant, form the tag set consisting of pre_tags + alternant + post_tags, -- and recursively split that tag set. local resulting_tag_sets = {} for _, first_level_tag_set in ipairs(tag) do local expanded_tag_set = {} extend(expanded_tag_set, pre_tags) -- The second level may have a string or a list. if type(first_level_tag_set) == "table" then extend(expanded_tag_set, first_level_tag_set) else insert(expanded_tag_set, first_level_tag_set) end extend(expanded_tag_set, post_tags) extend(resulting_tag_sets, split_two_level_multipart_tag_set(expanded_tag_set)) end return resulting_tag_sets end end end return {tag_set} end local function try_lang_specific_module(langcode, modules_tried, name, data) local lang_specific_module = form_of_lang_data_module_prefix .. langcode .. "/functions" local langdata = safe_require(lang_specific_module) if langdata then insert(modules_tried, lang_specific_module) if langdata.cat_functions then local fn = langdata.cat_functions[name] if fn then return fn(data), true end end end return nil, false end -- Call a named function, either from the lang-specific data in -- [[Module:form of/lang-specific/LANGCODE/functions]] or in [[Module:form of/functions]]. local function call_named_function(name, funtype, normalized_tag_set, lang, POS, pagename, lemmas) local data = { pagename = pagename or default_pagename or get_default_pagename(), lemmas = lemmas, tag_set = normalized_tag_set, lang = lang, POS = POS } local modules_tried = {} -- First try lang-specific. while lang do local retval, found_it = try_lang_specific_module(lang:getCode(), modules_tried, name, data) if found_it then return retval end -- If the language has a parent (i.e. a superordinate variety), try again with that. lang = lang:getParent() end -- Try lang-independent. insert(modules_tried, form_of_functions_module) local fn = (cat_functions or get_cat_functions())[name] if fn then return fn(data) end for i, modname in ipairs(modules_tried) do modules_tried[i] = "[[" .. modname .. "]]" end error(("No %s function named '%s' in %s"):format(funtype, name, list_to_text(modules_tried, nil, " or "))) end -- Given a tag from the current tag set (which may be a list in case of a multipart tag), -- and a tag from a categorization spec, check that the two match. -- (1) If both are strings, we just check for equality. -- (2) If the spec tag is a string and the tag set tag is a list (i.e. it originates from a -- multipart tag), we check that the spec tag is in the list. This is because we want to treat -- multipart tags in user-specified tag sets as if the user had specified multiple tag sets. -- For example, if the user said "1//3|s|pres|ind" and the categorization spec says {"has", "1"}, -- we want this to match, because "1//3|s|pres|ind" should be treated equivalently to two tag -- sets "1|s|pres|ind" and "3|s|pres|ind", and the former matches the categorization spec. -- (3) If the spec tag is a list (i.e. it originates from a multipart tag), we check that the -- tag set tag is also a list and is a superset of the spec tag. For example, if the categorization -- spec says {"has", "1//3"}, then the tag set tag must be a multipart tag that has both "1" and "3" -- in it. "1//3" works, as does "1//2//3". local function tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) if type(spec_tag) == "table" then if type(tag_set_tag) == "table" and is_subset_list(spec_tag, tag_set_tag) then return true end elseif type(tag_set_tag) == "table" then if contains(tag_set_tag, spec_tag) then return true end elseif tag_set_tag == spec_tag then return true end return false end -- Check that the current tag set matches the given spec tag. This means that any of the tags -- in the current tag set match, according to tag_set_tag_matches_spec_tag(); see above. If the -- current tag set contains only string tags (i.e. no multipart tags), and the spec tag is a -- string (i.e. not a multipart tag), this boils down to list containment, but it gets more -- complex when multipart tags are present. local function tag_set_matches_spec_tag(spec_tag, tag_set, lang) spec_tag = normalize_tag(spec_tag, lang) for _, tag_set_tag in ipairs(tag_set) do if tag_set_tag_matches_spec_tag(tag_set_tag, spec_tag) then return true end end return false end -- Check whether the given spec matches the current tag set. Two values are returned: -- (1) whether the spec matches the tag set; (2) the index of the category to add if -- the spec matches. local function check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if type(spec) == "boolean" then return spec elseif type(spec) ~= "table" then error("Wrong type of condition " .. spec .. ": " .. type(spec)) end local predicate = spec[1] if predicate == "has" then return tag_set_matches_spec_tag(spec[2], tag_set, lang), 3 elseif predicate == "hasall" then for _, tag in ipairs(spec[2]) do if not tag_set_matches_spec_tag(tag, tag_set, lang) then return false, 3 end end return true, 3 elseif predicate == "hasany" then for _, tag in ipairs(spec[2]) do if tag_set_matches_spec_tag(tag, tag_set, lang) then return true, 3 end end return false, 3 elseif predicate == "tags=" then local normalized_spec_tag_sets = normalize_tag_set(spec[2], lang) if #normalized_spec_tag_sets > 1 then error("Internal error: No support for conjoined shortcuts in category/label specs in " .. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|")) end local normalized_spec_tag_set = normalized_spec_tag_sets[1] -- Check for and disallow two-level multipart tags in the specs. FIXME: Remove this when we remove -- support for two-level multipart tags. for _, tag in ipairs(normalized_spec_tag_set) do if type(tag) == "table" then for _, subtag in ipairs(tag) do if type(subtag) == "table" then error("Internal error: No support for two-level multipart tags in category/label specs" .. "[[Module:form of/cats]] when processing spec tag set " .. concat(spec[2], "|")) end end end end -- Allow tags to be in different orders, and multipart tags to be in different orders. To handle this, -- we first check that both tag set tags and spec tags have the same length. If so, we sort the -- multipart tags in the tag set tags and spec tags, and then check that all tags in the spec tags are -- in the tag set tags. if #tag_set ~= #normalized_spec_tag_set then return false, 3 end local tag_set_tags = deep_copy(tag_set) for i=1,#tag_set_tags do if type(tag_set_tags[i]) == "table" then sort(tag_set_tags[i]) end if type(normalized_spec_tag_set[i]) == "table" then sort(normalized_spec_tag_set[i]) end end for i=1,#tag_set_tags do if not contains(tag_set_tags, normalized_spec_tag_set[i]) then return false, 3 end end return true, 3 elseif predicate == "p=" then return POS == normalize_pos(spec[2]), 3 elseif predicate == "pany" then for _, specpos in ipairs(spec[2]) do if POS == normalize_pos(specpos) then return true, 3 end end return false, 3 elseif predicate == "pexists" then return POS ~= nil, 2 elseif predicate == "not" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) return not condval, 3 elseif predicate == "and" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if condval then condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) end return condval, 4 elseif predicate == "or" then local condval = check_condition(spec[2], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if not condval then condval = check_condition(spec[3], tag_set, normalized_tag_set, lang, POS, pagename, lemmas) end return condval, 4 elseif predicate == "call" then return call_named_function(spec[2], "condition", normalized_tag_set, lang, POS, pagename, lemmas), 3 else error("Unrecognized predicate: " .. predicate) end end -- Process a given spec. This checks any conditions in the spec against the -- tag set, and insert any resulting categories into `categories`. Return value -- is true if the outermost condition evaluated to true and a category was inserted -- (this is used in {"cond" ...} conditions, which stop when a subcondition evaluates -- to true). local function process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) if not spec then return false elseif type(spec) == "string" then -- A category. Substitute POS request with user-specified part of speech or default. spec = spec:gsub("<<p=(.-)>>", function(default) return POS or normalize_pos(default) end) insert(categories, lang:getFullName() .. " " .. spec) return true elseif type(spec) == "table" and spec.labels then -- A label spec. for _, label in ipairs(spec.labels) do insert_if_not(labels, label) end return true elseif type(spec) ~= "table" then error("Wrong type of specification " .. spec .. ": " .. type(spec)) end local predicate = spec[1] if predicate == "multi" then for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2. process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end return true elseif predicate == "cond" then for _, sp in iterate_from(2, ipairs(spec)) do -- Iterate from 2. if process_spec(sp, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) then return true end end return false elseif predicate == "call" then return process_spec( call_named_function(spec[2], "spec", normalized_tag_set, lang, POS, pagename, lemmas), tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels ) else local condval, ifspec = check_condition(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas) if condval then process_spec(spec[ifspec], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) return true else process_spec(spec[ifspec + 1], tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) -- FIXME: Are we sure this is correct? return false end end end --[==[ Given a normalized tag set (i.e. as output by {normalize_tag_set()}; all tags are in canonical form, multipart tags are represented as lists, and two-level multipart tags as lists of lists), fetch the associated categories and labels. Return two values, a list of categories and a list of labels. `lang` is the language of term represented by the tag set, and `POS` is the user-provided part of speech (which may be {nil}).]==] function export.fetch_categories_and_labels(normalized_tag_set, lang, POS, pagename, lemmas) local categories, labels = {}, {} POS = normalize_pos(POS) -- First split any two-level multipart tags into multiple sets, to make our life easier. for _, tag_set in ipairs(split_two_level_multipart_tag_set(normalized_tag_set)) do local langcode = lang:getCode() local langspecs = (m_cats_data or get_m_cats_data())[langcode] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end local full_code = lang:getFullCode() if full_code ~= langcode then local langspecs = (m_cats_data or get_m_cats_data())[full_code] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end end if full_code ~= "und" then local langspecs = (m_cats_data or get_m_cats_data())["und"] if langspecs then for _, spec in ipairs(langspecs) do process_spec(spec, tag_set, normalized_tag_set, lang, POS, pagename, lemmas, categories, labels) end end end end return categories, labels end fetch_categories_and_labels = export.fetch_categories_and_labels local function format_labels(labels, data, notext) if labels and #labels > 0 then return show_labels{ labels = labels, lang = data.lang, sort = data.sort, nocat = data.nocat } .. (notext and (data.pretext or "") == "" and "" or " ") else return "" end end --[==[ Implementation of templates that display inflection tags, such as the general {{tl|inflection of}}, semi-specific variants such as {{tl|participle of}}, and specific variants such as {{tl|past participle of}}. `data` contains all the information controlling the display, with the following fields: * `.lang`: ('''''required''''') Language to use when looking up language-specific inflection tags, categories and labels, and for displaying categories and labels. * `.tags`: ('''''required''' unless `.tag_sets` is given'') List of non-canonicalized inflection tags. Multiple tag sets can be indicated by a {";"} as one of the tags, and tag-set properties may be attached to the last tag of a tag set. The tags themselves may come directly from the user (as in {{tl|inflection of}}); come partly from the user (as in {{tl|participle of}}, which adds the tag `part` to user-specified inflection tags); or be entirely specified by the template (as in {{tl|past participle of}}). * `.tag_sets`: ('''''required''' unless `.tags` is given'') List of non-canonicalized tag sets and associated per-tag-set properties. Each element of the list is an object of the form { {tags = {"TAG", "TAG", ...}, labels = {"LABEL", "LABEL", ...}}. If `.tag_sets` is specified, `.tags` should not be given and vice-versa. Specifying `.tag_sets` in place of tags allowed per-tag set labels to be specified; otherwise, there is no advantage. [[Module:pt-gl-inflections]] uses this functionality to supply labels like {"Brazil"} and {"Portugal"} associated with specific tag sets. * `.lemmas`: ('''''recommended''''') List of objects describing the lemma(s) of which the term in question is a non-lemma form. These are passed directly to {full_link()} in [[Module:links]]. Each object should have at minimum a `.lang` field containing the language of the lemma and a `.term` field containing the lemma itself. Each object is formatted using {full_link()} and then if there are more than one, they are joined using {serialCommaJoin()} in [[Module:table]]. Alternatively, `.lemmas` can be a string, which is displayed directly. If omitted entirely, no lemma links are shown and the connecting "of" is also omitted. * `.lemma_face`: ('''''recommended''''') "Face" to use when displaying the lemma objects. Usually should be set to {"term"}. * `.POS`: ('''''recommended''''') Categorizing part-of-speech tag. Comes from the {{para|p}} or {{para|POS}} argument of {{tl|inflection of}}. * `.pagename`: Page name of "current" page or nil to use the actual page title; for testing purposes. * `.conj`: Conjunction or separator to use when joining multiple lemma objects. Defaults to {"and"}. * `.enclitics`: List of enclitics to display after the lemmas, in parens. * `.enclitic_conj`: Conjunction or separator to use when joining multiple enclitics. Defaults to {"and"}. * `.no_format_categories`: If true, don't format the categories derived from the inflection tags; just return them. * `.sort`: Sort key for formatted categories. Ignored when `.no_format_categories` = {true}. * `.nocat`: Suppress computation of categories (even if `.no_format_categories` is not given). * `.notext`: Disable display of all tag text and `inflection of` text. (FIXME: Maybe not implemented correctly.) * `.nolink`: Suppress linking of terms in inflection tags. * `.capfirst`: Capitalize the first word displayed. * `.pretext`: Additional text to display before the inflection tags, but after any top-level labels. * `.posttext`: Additional text to display after the lemma links. * `.text_classes`: CSS classes used to wrap the tag text and lemma links. Default is {"form-of-definition use-with-mention"}. * `.lemma_classes`: Additional CSS classes used to wrap the lemma links. Default is {"form-of-definition-link"}. * `.joiner`: Override the joiner (normally a slash) used to join multipart tags. You should normally not specify this. * `.nowrap`: Do not wrap the form-of definitions in a span, unless `.text_classes` is specified. * `.ok_to_destructively_modify`: If set, data structures (including the nested lemma structures) can be modified in-place to save memory; otherwise they will be copied before modifying. A typical call might look like this (for {{m+|es|amo}}): { local lang = require("Module:languages").getByCode("es") local lemma_obj = { lang = lang, term = "amar", } return m_form_of.tagged_inflections({ lang = lang, tags = {"1", "s", "pres", "ind"}, lemmas = {lemma_obj}, lemma_face = "term", POS = "verb" }) } Normally, one value is returned, the formatted text, which has appended to it the formatted categories derived from the tag-set-related categories generated by the specs in [Module:form of/cats]]. To suppress this, set `data.no_format_categories` = {true}, in which case two values are returned, the formatted text without any formatted categories appended and a list of the categories to be formatted. NOTE: There are two sets of categories that may be generated: (1) categories derived directly from the tag sets, as specified in [[Module:form of/cats]]; (2) categories derived from tag-set labels, either (a) set explicitly by the caller in `data.tag_sets`, (b) specified by the user using `<lb:...>` attached to the last tag in a tag set, or (c) specified in [[Module:form of/cats]]. The second type (label-related categories) are currently not returned in the second return value of {tagged_inflections()}, and are currently inserted into the output text even if `data.no_format_categories` is set to {true}; but they can be suppressed by setting `data.nocat` = {true} (which also suppresses the first type of categories, those derived directly from tag sets, even if `data.no_format_categories` is set to {true}).]==] function export.tagged_inflections(data) if not data.tags and not data.tag_sets then error("First argument must be a table of arguments, and `.tags` or `.tag_sets` must be specified") end if data.tags and data.tag_sets then error("Both `.tags` and `.tag_sets` cannot be specified") end local tag_sets = data.tag_sets if not tag_sets then tag_sets = split_tag_set(data.tags) for i, tag_set in ipairs(tag_sets) do tag_sets[i] = parse_tag_set_properties(tag_set) end end local inflections = {} local categories = {} for _, tag_set in ipairs(tag_sets) do local normalized_tag_sets = normalize_tag_set(tag_set.tags, data.lang, "do-track") for _, normalized_tag_set in ipairs(normalized_tag_sets) do local this_categories, this_labels = fetch_categories_and_labels(normalized_tag_set, data.lang, data.POS, data.pagename, type(data.lemmas) == "table" and data.lemmas or nil) if not data.nocat then extend(categories, this_categories) end local cur_infl = get_tag_set_display_form(normalized_tag_set, data.lang, data.joiner, data.nolink) if #cur_infl > 0 then if tag_set.labels then this_labels = append(tag_set.labels, this_labels) end insert(inflections, {infl_text = cur_infl, labels = this_labels}) end end end local overall_labels, need_per_tag_set_labels for _, inflection in ipairs(inflections) do if overall_labels == nil then overall_labels = inflection.labels elseif not deep_equals(overall_labels, inflection.labels) then need_per_tag_set_labels = true overall_labels = nil break end end if not need_per_tag_set_labels then for _, inflection in ipairs(inflections) do inflection.labels = nil end end local format_data = shallow_copy(data) local of_text = data.lemmas and " යන යෙදුමෙහි " or "" local formatted_text, this_categories if #inflections == 1 then if need_per_tag_set_labels then error("Internal error: need_per_tag_set_labels should not be set with one inflection") end format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or (of_text .. (data.capfirst and ucfirst(inflections[1].infl_text) or inflections[1].infl_text))) formatted_text, this_categories = format_form_of(format_data) else format_data.text = format_labels(overall_labels, data, data.notext) .. (data.pretext or "") .. (data.notext and "" or (of_text .. (data.capfirst and "Inflection" or "inflection"))) format_data.posttext = (data.posttext or "") .. ":" local link link, this_categories = format_form_of(format_data) local text_classes = data.text_classes if text_classes == nil and not data.nowrap then text_classes = "form-of-definition use-with-mention" end for i, inflection in ipairs(inflections) do inflections[i] = "\n## " .. format_labels(inflection.labels, data, false) .. wrap_in_span(inflection.infl_text, text_classes) end formatted_text = link .. concat(inflections) end if this_categories[1] then extend(categories, this_categories) end if not data.no_format_categories then if categories[1] then formatted_text = formatted_text .. format_categories(categories, data.lang, data.sort, nil, export.force_cat) end return formatted_text end return formatted_text, categories end function export.dump_form_of_data(_frame) local data = { require(form_of_data1_module), require(form_of_data2_module) } return require(json_module).toJSON(data) end export.form_of_cats_module = form_of_cats_module export.form_of_data1_module = form_of_data1_module export.form_of_data2_module = form_of_data2_module export.form_of_functions_module = form_of_functions_module export.form_of_lang_data_module_prefix = form_of_lang_data_module_prefix export.headword_data_module = headword_data_module -- so all form-of modules stay in sync return export ravlzu22ohistkelvbmtark9z0qk8iw Module:form of/templates 828 5229 238968 221698 2026-10-07T07:23:07Z en>Octahedron80 0 apply stripDiacritics before checking pages 238968 Scribunto text/plain local export = {} local debug_track_module = "Module:debug/track" local form_of_module = "Module:form of" local functions_module = "Module:fun" local headword_data_module = "Module:headword/data" local languages_module = "Module:languages" local load_module = "Module:load" local parameters_module = "Module:parameters" local parameter_utilities_module = "Module:parameter utilities" local parse_interface_module = "Module:parse interface" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local utilities_module = "Module:utilities" local insert = table.insert local ipairs = ipairs local pairs = pairs local require = require local boolean_param = {type = "boolean"} -- FIXME: Finish [[Module:format utilities]]. -- local allowed_conj_set = require(format_utilities_module).allowed_conj_set_for_join_segments local allowed_conj_set = {["and"] = true, ["or"] = true, ["and/or"] = true} --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function decode_entities(...) decode_entities = require(string_utilities_module).decode_entities return decode_entities(...) end local function extend(...) extend = require(table_module).extend return extend(...) end local function format_categories(...) format_categories = require(utilities_module).format_categories return format_categories(...) end local function format_form_of(...) format_form_of = require(form_of_module).format_form_of return format_form_of(...) end local function get_lang(...) get_lang = require(languages_module).getByCode return get_lang(...) end local function gsplit(...) gsplit = require(string_utilities_module).gsplit return gsplit(...) end local function is_callable(...) is_callable = require(functions_module).is_callable return is_callable(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function parse_inline_modifiers(...) parse_inline_modifiers = require(parse_interface_module).parse_inline_modifiers return parse_inline_modifiers(...) end local function pattern_escape(...) pattern_escape = require(string_utilities_module).pattern_escape return pattern_escape(...) end local function process_params(...) process_params = require(parameters_module).process return process_params(...) end local function safe_load_data(...) safe_load_data = require(load_module).safe_load_data return safe_load_data(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function split_tag_set(...) split_tag_set = require(form_of_module).split_tag_set return split_tag_set(...) end local function tagged_inflections(...) tagged_inflections = require(form_of_module).tagged_inflections return tagged_inflections(...) end local function trim(...) trim = require(string_utilities_module).trim return trim(...) end local function ucfirst(...) ucfirst = require(string_utilities_module).ucfirst return ucfirst(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local force_cat local function get_force_cat() force_cat, get_force_cat = require(form_of_module).force_cat, nil return force_cat end local m_form_of_pos local function get_m_form_of_pos() m_form_of_pos, get_m_form_of_pos = load_data(headword_data_module).pos_aliases, nil return m_form_of_pos end local module_prefix local function get_module_prefix() module_prefix, get_module_prefix = require(form_of_module).form_of_lang_data_module_prefix, nil return module_prefix end --[==[ intro: This module contains code that directly implements {{tl|form of}}, {{tl|inflection of}}, and the various other [[:Category:Form-of templates|form-of templates]]. It is meant to be called directly from templates. See also [[Module:form of]], which contains the underlying implementing code and is meant to be called from other modules. ]==] -- Add tracking category for PAGE when called from TEMPLATE. The tracking category linked to is -- [[Wiktionary:Tracking/form of/TEMPLATE/PAGE]]. If TEMPLATE is omitted, the tracking category is of the form -- [[Wiktionary:Tracking/form of/PAGE]]. local function track(page, template) debug_track("form of/" .. (template and template .. "/" or "") .. page) end local function get_common_template_params() return { -- Named params not controlling link display ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, ["notext"] = boolean_param, ["sort"] = true, ["enclitic"] = true, -- FIXME! The following should only be available when withcap=1 in invocation args or when withencap=1 and the -- language is "en". Before doing that, need to remove all uses of nocap= in other circumstances. ["nocap"] = boolean_param, ["addl"] = true, -- additional text to display at the end, before the closing </span> ["pagename"] = true, -- for testing, etc. } end -- Split TAGSPECS (inflection tag specifications) on SPLIT_REGEX, which -- may be nil for no splitting. local function split_inflection_tags(tagspecs, split_regex) if not split_regex then return tagspecs end local inflection_tags = {} for _, tagspec in ipairs(tagspecs) do for tag in gsplit(tagspec, split_regex) do insert(inflection_tags, tag) end end return inflection_tags end local function parse_terms_with_inline_modifiers(paramname, val, param_mods, lang) local function generate_obj(term) return {lang = lang, term = decode_entities(term)} end return parse_inline_modifiers(val, { paramname = paramname, param_mods = param_mods, generate_obj = generate_obj, splitchar = ",", outer_container = {}, }) end -- Need to do what [[Module:parameters]] does to string arguments from parent_args as we're running this -- before calling [[Module:parameters]] on parent_args. local function ine(arg) if not arg then return nil end arg = trim(arg) return arg ~= "" and arg or nil end local function add_base_lemma_params(parent_args, iargs, params, compat) -- Check the language-specific data for additional base lemma params. But if there's no language-specific data, -- attempt any parent varieties as well (i.e. superordinate varieties). local lang = get_lang(ine(parent_args[compat and "lang" or 1]) or ine(iargs.lang) or "und", nil, true) while lang do local langdata = safe_load_data((module_prefix or get_module_prefix()) .. lang:getCode()) if langdata then local base_lemma_params = langdata.base_lemma_params if base_lemma_params then for _, param in ipairs(base_lemma_params) do params[param.param] = true end return base_lemma_params end end lang = lang:getParent() end end --[=[ Modify `params` in-place by adding parameters that control the link to the main entry and any base lemmas. `term_param` is the number of the param specifying the main entry itself; `term_param` + 1 will be the display text, and `term_param` + 2 will be the gloss, unless `no_numbered_gloss` is given. The base lemma parameters are determined by attempting to load language-specific data for the language of the page; this comes from |lang= if `compat` is given, else from |1=. ]=] local function add_link_and_base_lemma_params(iargs, parent_args, params, term_param, compat, no_numbered_gloss) local base_lemma_params if not iargs.nolink and not iargs.linktext then -- Numbered params controlling link display if iargs.with_multiple_parts then params[term_param] = {list = true, allow_holes = true} else params[term_param + 1] = {alias_of = "alt"} if not no_numbered_gloss then params[term_param + 2] = {alias_of = "t"} end params[term_param] = true end base_lemma_params = add_base_lemma_params(parent_args, iargs, params, compat) end return base_lemma_params end local function handle_withdot_withcap(iargs, params) local ignored_tracked_params = {} if iargs.withdot then params.dot = true params.nodot = boolean_param end if iargs.withcap and iargs.withencap then error("Internal error: Can specify only one of withcap= and withencap=") end if not iargs.withcap then params.cap = boolean_param ignored_tracked_params.nocap = iargs.withencap and "non-english" or "always" end return ignored_tracked_params end --[=[ Construct and return the full definition line for a form-of-type template invocation. `data` is an object with the following fields: * `template`: Approximate template name, for debug tracking; * `iargs`: processed invocation arguments; * `parent_args`: raw parent args from `frame:getParent().args`; * `params`: partially constructed params structure of the sort passed to `process()` in [[Module:parameters]], but without any link params; * `ignored_tracked_params`: params that are ignored but should be tracked, to be eventually removed; * `term_param`: the parent argument specifying the main entry; * `compat`: true if the language code is found in args.lang instead of args[1]; * `base_lemma_params`: if non-nil, a list of base lemma param objects of the sort stored in the language-specific data; * `do_form_of`: a function of one argument, `lemma_data`, that returns the actual definition-line text and any language-specific categories. See below. This function does several things: # If link parameters are called for (neither `iargs.nolink` nor `iargs.linktext` are given), augment the `params` structure with separate link parameters. # Modify the parent args as appropriate if invocation arguments def= or ignore= are given. # Parse the parent args, both for separate parameter properties and inline modifiers on the term parameter (which may consist of multiple comma-separated terms). # Compute categories to add to the page, including language-specific categories and any categories requested by the invocation or parent args. # Parse enclitic and extra base lemma parameters. # Construct the actual text using `do_form_of`. # Add a terminating period/dot as appropriate, along with the formatted categories. `do_form_of` takes one argument, `lemma_data`, which looks like this: { lang = LANG, args = {ARG = VALUE, ARG = VALUE, ...}, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, enclitics = {ENCLITIC_OBJ, ENCLITIC_OBJ, ...}, base_lemmas = {BASE_LEMMA_OBJ, BASE_LEMMA_OBJ, ...}, categories = {"CATEGORY", "CATEGORY", ...}, posttext = "POSTTEXT" or nil, } where * LANG is the language code; * ARGS is the parsed arguments, based on what the user specified; * LEMMAS is a sequence of objects specifying the main entries/lemmas, as passed to full_link in [[Module:links]]; however, if the invocation argument linktext= is given, it will be a string consisting of that text, and if the invocation argument nolink= is given, it will be nil; * ENCLITICS is nil or a sequence of objects specifying the enclitics, as passed to full_link in [[Module:links]]; * BASE_LEMMA_OBJ is a sequence of objects specifying the base lemma(s), which are used when the lemma is itself a form of another lemma (the base lemma), e.g. a comparative, superlative or participle; each object is of the form { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...} } where PARAM_OBJ describes the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas) and LEMMA_OBJ is of the same format of ENCLITIC_OBJ, i.e. an object suitable to be passed to full_link in [[Module:links]]; PARAM_OBJ is of the format { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{inflection of}} etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as {"comd"} or {"past", "part"}; * CATEGORIES is the categories to add the page to (consisting of any categories specified in the invocation or parent args and any tracking categories, but not any additional lang-specific categories that may be added by {{inflection of}} or similar templates); * POSTTEXT is text to display at the end of the form-of text, before the final </span> (or at the end of the first line, before the colon, in a multiline {{infl of}} call). `do_form_of` should return two arguments: (1) The actual definition-line text, marked up appropriately with <span>...</span> but without any terminating period/dot. (2) Any extra categories to add the page to (other than those that can be derived from parameters specified to the invocation or parent arguments, which will automatically be added to the page). ]=] local function construct_form_of_text(data) local template, iargs, parent_args, params, no_numbered_gloss, do_form_of = data.template, data.iargs, data.parent_args, data.params, data.no_numbered_gloss, data.do_form_of local term_param = iargs.term_param local compat = iargs.lang or parent_args.lang term_param = term_param or compat and 1 or 2 -- Numbered params params[compat and "lang" or 1] = { required = not iargs.lang, type = "language", default = iargs.lang or "und" } -- Error to catch most uses of old-style parameters for {{contraction of}}. (FIXME: Remove eventually.) if iargs.with_multiple_parts then if ine(parent_args[term_param + 2]) and not ine(parent_args[term_param + 1]) and not ine(parent_args.tr2) and not ine(parent_args.ts2) and not ine(parent_args.t2) and not ine(parent_args.gloss2) and not ine(parent_args.g2) and not ine(parent_args.alt2) then error(("You specified a term in %s= and not one in %s=. You probably meant to use t= to specify a gloss instead. " .. "If you intended to specify two terms, put the second term in %s=."):format(term_param + 2, term_param + 1, term_param + 1)) end if not ine(parent_args[term_param + 1]) and not ine(parent_args.alt2) and not ine(parent_args.tr2) and not ine(parent_args.ts2) and ine(parent_args.g2) then error(("You specified a gender in g2= but no term in %s=. You were probably trying to specify two genders for " .. "a single term. To do that, put both genders in g=, comma-separated."):format(term_param + 1)) end end local base_lemma_params = add_link_and_base_lemma_params(iargs, parent_args, params, term_param, compat, no_numbered_gloss) local ignored_tracked_params = handle_withdot_withcap(iargs, params) --[=[ Process parent arguments. This is similar to the following: require("Module:parameters").process(parent_args, params) but in addition it does the following: (1) Supplies default values for unspecified parent arguments as specified in DEFAULTS, which consist of specs of the form "ARG=VALUE". These are added to the parent arguments prior to processing, so boolean and number parameters will process the value appropriately. (2) Removes parent arguments specified in IGNORESPECS, which consist either of bare argument names to remove, or list-argument names to remove of the form "ARG:list". (3) Tracks the use of any parent arguments specified in TRACKED_PARAMS, which is a set where the keys are arguments as they exist after processing (hence numeric arguments should be numbers, not strings) and the values should be boolean true. ]=]-- local defaults = iargs.def local ignorespecs = iargs.ignore if defaults[1] or ignorespecs[1] then local new_parent_args = {} for _, default in ipairs(defaults) do local defparam, defval = default:match("^(.-)=(.*)$") if not defparam then error("Bad default spec " .. default) end new_parent_args[defparam] = defval end local params_to_ignore = {} local numbered_list_params_to_ignore = {} local named_list_params_to_ignore = {} for _, ignorespec in ipairs(ignorespecs) do for ignore in gsplit(ignorespec, ",") do local param = ignore:match("^(.*):list$") if param then if param:match("^%d+$") then insert(numbered_list_params_to_ignore, tonumber(param)) else insert(named_list_params_to_ignore, "^" .. pattern_escape(param) .. "%d*$") end else if ignore:match("^%d+$") then ignore = tonumber(ignore) end params_to_ignore[ignore] = true end end end for k, v in pairs(parent_args) do if not params_to_ignore[k] then local ignore_me = false if type(k) == "number" then for _, lparam in ipairs(numbered_list_params_to_ignore) do if k >= lparam then ignore_me = true break end end else for _, lparam in ipairs(named_list_params_to_ignore) do if k:match(lparam) then ignore_me = true break end end end if not ignore_me then new_parent_args[k] = v end end end parent_args = new_parent_args end local param_mods_with_conj, param_mods_without_conj local function get_param_mods(with_conj) if with_conj then if not param_mods_with_conj then param_mods_with_conj = require(parameter_utilities_module).construct_param_mods { {group = {"link", "q", "l", "ref"}}, {param = "conj", set = allowed_conj_set, overall = true}, } end return param_mods_with_conj else if not param_mods_without_conj then param_mods_without_conj = require(parameter_utilities_module).construct_param_mods { {group = {"link", "q", "l", "ref"}}, -- Override lit= to have a separate overall value {param = "lit", separate_no_index = true}, } end return param_mods_without_conj end end local terms, args if iargs.nolink or iargs.linktext then args = process_params(parent_args, params) else local m_param_utils = require(parameter_utilities_module) if iargs.with_multiple_parts then terms, args = m_param_utils.parse_list_with_inline_modifiers_and_separate_params { params = params, param_mods = get_param_mods(false), raw_args = parent_args, termarg = term_param, track_module = "form of" .. (template and "/" .. template or ""), lang = compat and "lang" or 1, sc = "sc.default", parse_lang_prefix = true, default_separator = " +&lrm; ", special_separators = {[";"] = " or "}, } else terms, args = m_param_utils.parse_term_with_inline_modifiers_and_separate_params { params = params, param_mods = get_param_mods("with conj"), raw_args = parent_args, termarg = term_param, track_module = "form of" .. (template and "/" .. template or ""), lang = compat and "lang" or 1, sc = "sc", parse_lang_prefix = true, make_separate_g_into_list = true, splitchar = ",", subitem_param_handling = "last", } end end local lang = args[compat and "lang" or 1] -- Tracking for certain user-specified params. This is generally used for -- parameters that we accept but ignore, so that we can eventually remove -- all uses of these params and stop accepting them. if ignored_tracked_params then for ignored_tracked_param, condition in pairs(ignored_tracked_params) do if parent_args[ignored_tracked_param] and (condition ~= "non-english" or lang:getCode() ~= "en") then track("arg/" .. ignored_tracked_param, template) track("arg/" .. ignored_tracked_param) end end end -- Determine categories for the page, including tracking categories local categories = {} if not args.nocat then for _, cat in ipairs(iargs.cat) do insert(categories, lang:getFullName() .. " " .. cat) end end for _, cat in ipairs(args.cat) do insert(categories, lang:getFullName() .. " " .. cat) end -- Format the link, preceding text and categories local function add_term_tracking_categories(term) local term_title = lang:stripDiacritics(term) -- add tracking category if term is same as page title if term_title and mw.loadData("Module:headword/data").pagename == term_title then insert(categories, "Forms linking to themselves") end -- maybe add tracking category if primary entry doesn't exist (this is an -- expensive call so we don't do it by default) if iargs.noprimaryentrycat and term_title and mw.title.getCurrentTitle().nsText == "" and not mw.title.new(term_title):getContent() then insert(categories, lang:getFullName() .. " " .. iargs.noprimaryentrycat) end end local lemmas if iargs.nolink then lemmas = nil elseif iargs.linktext then lemmas = iargs.linktext else if iargs.with_multiple_parts then lemmas = terms else lemmas = terms.terms end if not lemmas[1] then if mw.title.getCurrentTitle().nsText == "Template" then lemmas[1] = { lang = lang, term = "term" } else error("No linked-to term specified") end end for _, termobj in ipairs(lemmas) do if termobj.term then add_term_tracking_categories(termobj.term) end -- NOTE: Formerly, template arg sc= overrode inline modifier <sc:...>, which seems backwards, so I've -- changed it. Hopefully nothing depended on the old behavior. end end local enclitics, enclitic_conj if args.enclitic then local enclitics_obj = parse_terms_with_inline_modifiers("enclitic", args.enclitic, get_param_mods("with conj"), lang) enclitics = enclitics_obj.terms enclitic_conj = enclitics_obj.conj end local base_lemmas = {} if base_lemma_params then for _, base_lemma_param_obj in ipairs(base_lemma_params) do local param = base_lemma_param_obj.param if args[param] then local base_lemmas_obj = parse_terms_with_inline_modifiers(param, args[param], get_param_mods("with conj"), lang) insert(base_lemmas, { paramobj = base_lemma_param_obj, lemmas = base_lemmas_obj.terms, conj = base_lemmas_obj.conj, }) end end end local posttext = iargs.posttext local addl = args.addl if addl then posttext = posttext or "" if addl:find("^[;:]") then posttext = posttext .. addl elseif addl:find("^_") then posttext = posttext .. " " .. addl:sub(2) else posttext = posttext .. ", " .. addl end end local conj if iargs.with_multiple_parts then conj = false -- signals to use 'separator' field else conj = terms and terms.conj or iargs.conj end local lemma_data = { lang = lang, args = args, lemmas = lemmas, conj = conj, enclitics = enclitics, enclitic_conj = enclitic_conj, base_lemmas = base_lemmas, categories = categories, posttext = posttext, lit = iargs.with_multiple_parts and args.lit.default or nil, } local form_of_text, lang_cats = do_form_of(lemma_data) extend(lemma_data.categories, lang_cats) local text = form_of_text .. ( args.nodot and "" or args.dot or iargs.withdot and "." or "" ) if not lemma_data.categories[1] then return text end return text .. format_categories(lemma_data.categories, lemma_data.lang, args.sort, -- If lemma_is_sort_key is given, supply the first lemma term as the sort base if possible. If sort= is given, -- it will override the base; otherwise, the base will be converted appropriately to a sort key using the -- same algorithm applied to pagenames. iargs.lemma_is_sort_key and type(lemma_data.lemmas) == "table" and lemma_data.lemmas[1].term, -- Supply the first lemma's script for sort key computation. force_cat or get_force_cat(), type(lemma_data.lemmas) == "table" and lemma_data.lemmas[1].sc) end -- Invocation parameters shared between form_of_t(), tagged_form_of_t() and inflection_of_t(). `calling_func` is the -- invoking function ("form_of_t", "tagged_form_of_t" or "inflection_of_t"), for handling parameters shared by two but -- not all three invoking functions. local function get_common_invocation_params(calling_func) local iparams = { ["term_param"] = {type = "number"}, ["lang"] = true, -- To be used as the default code in params. ["sc"] = {type = "script"}, ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, ["ignore"] = {list = true}, ["def"] = {list = true}, ["conj"] = {set = allowed_conj_set, default = "and"}, ["withcap"] = boolean_param, ["withencap"] = boolean_param, ["withdot"] = boolean_param, ["nolink"] = boolean_param, ["linktext"] = true, ["posttext"] = true, ["noprimaryentrycat"] = true, ["lemma_is_sort_key"] = true, } if calling_func ~= "inflection_of_t" then iparams.with_multiple_parts = boolean_param end return iparams end local function should_ucfirst_text(args, iargs, lang) local code = lang:getCode() return args.cap or (iargs.withcap or iargs.withencap and code == "en" or code == "mul") and not args.nocap end --[==[ Function that implements {{tl|form of}} and the various more specific form-of templates (but not {{tl|inflection of}} or templates that take tagged inflection parameters). Invocation params: ; {{para|1|req=1}} : Text to display before the link. ; {{para|term_param}} : Numbered param holding the term linked to. Other numbered params come after. Defaults to 1 if invocation or template param {{para|lang}} is present, otherwise 2. ; {{para|with_multiple_parts|1}} : If specified, higher numbered parameters above the numbered param in {{para|term_param}} specify additional parts out of which the term was constructed, for use by templates like {{tl|contraction of}}. (If not specified, the parameter at <code><var>term_param</var> + 1</code> is the display form, same as {{para|alt}}, and the parameter at at <code><var>term_param</var> + 2</code> is the gloss, same as {{para|t}}.) ; {{para|lang}} : Default language code for language-specific templates. If specified, no language code needs to be specified, and if specified it needs to be set using {{para|lang}}, not {{para|1}}. ; {{para|sc}} : Default script code for language-specific templates. The script code can still be overridden using template param {{para|sc}}. ; {{para|cat}}, {{para|cat2}}, ...: : Categories to place the page into. The language name will automatically be prepended. Note that there is also a template param {{para|cat}} to specify categories at the template level. Use of {{para|nocat}} disables categorization of categories specified using invocation param {{para|cat}}, but not using template param {{para|cat}}. A single param can specify multiple comma-separated categories if no space follows the comma. ; {{para|ignore}}, {{para|ignore2}}, ...: : One or more template params to silently accept and ignore. Useful e.g. when the template takes additional parameters such as {{para|from}} or {{para|POS}}. Each value is a comma-separated list of either bare parameter names or specifications of the form `PARAM:list` to specify that the parameter is a list parameter. ; {{para|def}}, {{para|def2}}, ...: : One or more default values to supply for template args. For example, specifying {{para|def|2=tr=-}} causes the default for template param {{para|tr}} to be `-`. Actual template params override these defaults. ; {{para|withcap|1}} : Capitalize the first character of the text preceding the link, unless template param {{para|nocap}} is given. ; {{para|withencap|1}} : Capitalize the first character of the text preceding the link if the language is English and template param {{para|nocap}} is not given. ; {{para|withdot|1}} : Add a final period after the link, unless template param {{para|nodot}} is given to suppress the period, or {{para|dot}} is given to specify an alternative punctuation character. ; {{para|nolink|1}} : Suppress the display of the link. If specified, none of the template params that control the link ({{para|<var>term_param</var>}}, {{para|<var>term_param</var> + 1}}, {{para|<var>term_param</var> + 2}}, {{para|t}}, {{para|gloss}}, {{para|sc}}, {{para|tr}}, {{para|ts}}, {{para|pos}}, {{para|g}}, {{para|id}}, {{para|lit}}) will be available. If the calling template uses any of these parameters, they must be ignored using {{para|ignore}}. {{para|linktext}} : Override the display of the link with the specified text. This is useful if a custom template is available to format the link (e.g. in Hebrew, Chinese and Japanese). If specified, none of the template params that control the link ({{para|<var>term_param</var>}}, {{para|<var>term_param</var> + 1}}, {{para|<var>term_param</var> + 2}}, {{para|t}}, {{para|gloss}}, {{para|sc}}, {{para|tr}}, {{para|ts}}, {{para|pos}}, {{para|g}}, {{para|id}}, {{para|lit}}) will be available. If the calling template uses any of these parameters, they must be ignored using {{para|ignore}}. ; {{para|posttext}} : Additional text to display directly after the formatted link, before any terminating period/dot and inside of `<span class='use-with-mention'>`. ; {{para|noprimaryentrycat}} : Category to add the page to if the primary entry linked to doesn't exist. The language name will automatically be prepended. ; {{para|lemma_is_sort_key|1}} : If the user didn't specify a sort key, use the lemma as the sort key (instead of the page itself). ]==] function export.form_of_t(frame) local iparams = get_common_invocation_params("form_of_t") iparams[1] = {required = true} local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() if next(iargs.cat) then params.nocat = boolean_param end return construct_form_of_text { template = "form-of-t", iargs = iargs, parent_args = parent_args, params = params, do_form_of = function(lemma_data) local args = lemma_data.args local text if args.notext then text = "" else text = iargs[1] if should_ucfirst_text(args, iargs, lemma_data.lang) then text = ucfirst(text) end end -- This returns two values, which we pass up to the caller. return format_form_of { lang = lemma_data.lang, text = text, lemmas = lemma_data.lemmas, conj = lemma_data.conj, enclitics = lemma_data.enclitics, base_lemmas = lemma_data.base_lemmas, lemma_face = "term", lit = lemma_data.lit, posttext = lemma_data.posttext } end } end --[=[ Construct and return the full definition line for a form-of-type template invocation that is based on inflection tags. This is a wrapper around construct_form_of_text() and takes the following arguments: processed invocation arguments IARGS, processed parent arguments ARGS, TERM_PARAM (the parent argument specifying the main entry), COMPAT (true if the language code is found in args.lang instead of args[1]), and TAGS, the list of (non-canonicalized) inflection tags. It returns that actual definition-line text including terminating period/full-stop, formatted categories, etc. and should be directly returned as the template function's return value. ]=] local function construct_tagged_form_of_text(data) local template, iargs, parent_args, params, no_numbered_gloss, tags = data.template, data.iargs, data.parent_args, data.params, data.no_numbered_gloss, data.tags -- Named params not controlling link display -- Always included because lang-specific categories may be added params.nocat = boolean_param params.p = true params.POS = {alias_of = "p"} return construct_form_of_text { template = template, iargs = iargs, parent_args = parent_args, params = params, no_numbered_gloss = no_numbered_gloss, do_form_of = function(lemma_data) local args = lemma_data.args if is_callable(tags) then tags = tags(args) end -- NOTE: tagged_inflections returns two values, so we do too. return tagged_inflections { lang = lemma_data.lang, tags = tags, lemmas = lemma_data.lemmas, conj = lemma_data.conj, enclitics = lemma_data.enclitics, enclitic_conj = lemma_data.enclitic_conj, base_lemmas = lemma_data.base_lemmas, lemma_face = "term", POS = args.p, pagename = args.pagename, -- Set no_format_categories because we do it ourselves in construct_form_of_text(). no_format_categories = true, nocat = args.nocat, notext = args.notext, capfirst = should_ucfirst_text(args, iargs, lemma_data.lang), posttext = lemma_data.posttext, } end } end --[==[ Function that implements form-of templates that are defined by specific tagged inflections (typically a template referring to a non-lemma inflection, such as {{tl|plural of}}). This works exactly like {form_of_t()} except that the "form of" text displayed before the link is based off of a pre-specified set of inflection tags (which will be appropriately linked to the glossary) instead of arbitrary text. From the user's perspective, there is no difference between templates implemented using {form_of_t()} and {tagged_form_of_t()}; they accept exactly the same parameters and work the same. See also {inflection_of_t()} below, which is intended for templates with user-specified inflection tags. Invocation params: ; {{para|1|req=1}}, {{para|2}}, ... : One or more inflection tags describing the inflection in question. ; {{para|split_tags}} : If specified, character to split specified inflection tags on. This allows multiple tags to be included in a single argument, simplifying template code. ; {{para|term_param}} ; {{para|with_multiple_parts|1}} ; {{para|lang}} ; {{para|sc}} ; {{para|cat}}, {{para|cat2}}, ... ; {{para|ignore}}, {{para|ignore2}}, ... ; {{para|def}}, {{para|def2}}, ... ; {{para|withcap|1}} ; {{para|withencap|1}} ; {{para|withdot|1}} ; {{para|nolink|1}} ; {{para|linktext}} ; {{para|posttext}} ; {{para|noprimaryentrycat}} ; {{para|lemma_is_sort_key|1}} : All of these are the same as in {form_of_t()}. ]==] function export.tagged_form_of_t(frame) local iparams = get_common_invocation_params("tagged_form_of_t") iparams[1] = {list = true, required = true} iparams.split_tags = true local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() return construct_tagged_form_of_text { template = "tagged-form-of-t", iargs = iargs, parent_args = parent_args, params = params, tags = split_inflection_tags(iargs[1], iargs.split_tags), } end --[==[ Function that implements {{tl|inflection of}} and certain semi-specific variants, such as {{tl|participle of}} and {{tl|past participle form of}}. This function is intended for templates that allow the user to specify a set of inflection tags. It works similarly to {form_of_t()} and {tagged_form_of_t()} except that the calling convention for the calling template is : { {{TEMPLATE|LANG|MAIN_ENTRY_LINK|MAIN_ENTRY_DISPLAY_TEXT|TAG|TAG|...}}} instead of : { {{TEMPLATE|LANG|MAIN_ENTRY_LINK|MAIN_ENTRY_DISPLAY_TEXT|GLOSS}}} Note that there isn't a numbered parameter for the gloss, but it can still be specified using {{para|t}} or {{para|gloss}}. Invocation params: ; {{para|preinfl}}, {{para|preinfl2}}, ... : Extra inflection tags to automatically prepend to the tags specified by the template. ; {{para|postinfl}}, {{para|postinfl2}}, ... : Extra inflection tags to automatically append to the tags specified by the template. Used for example by {{tl|past participle form of}} to add the tags `of the|past|p` onto the user-specified tags, which indicate which past participle form the page refers to. ; {{para|split_tags}} : If specified, character to split specified inflection tags on. This allows multiple tags to be included in a single argument, simplifying template code. Note that this applies *ONLY* to inflection tags specified in the invocation arguments using {{para|preinfl}} or {{para|postinfl}}, not to user-specified inflection tags. ; {{para|term_param}} ; {{para|lang}} ; {{para|sc}} ; {{para|cat}}, {{para|cat2}}, ... ; {{para|ignore}}, {{para|ignore2}}, ... ; {{para|def}}, {{para|def2}}, ... ; {{para|withcap|1}} ; {{para|withencap|1}} ; {{para|withdot|1}} ; {{para|nolink|1}} ; {{para|linktext}} ; {{para|posttext}} ; {{para|noprimaryentrycat}} ; {{para|lemma_is_sort_key|1}} : All of these are the same as in {form_of_t()}. ]==] function export.inflection_of_t(frame) local iparams = get_common_invocation_params("inflection_of_t") iparams.preinfl = {list = true} iparams.postinfl = {list = true} iparams.split_tags = true local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() local compat = iargs.lang or parent_args.lang local tagsind = (iargs.term_param or compat and 1 or 2) + 2 params[tagsind] = {list = true, -- at least one inflection tag is required unless preinfl or postinfl tags are given required = #iargs.preinfl == 0 and #iargs.postinfl == 0} return construct_tagged_form_of_text { template = "inflection-of-t", iargs = iargs, parent_args = parent_args, params = params, no_numbered_gloss = true, tags = function(args) local infls if not next(iargs.preinfl) and not next(iargs.postinfl) then -- If no preinfl or postinfl tags, just use the user-specified tags directly. infls = args[tagsind] else -- Otherwise, we need to prepend the preinfl tags and postpend the postinfl tags. If there's only one tag set -- (no semicolon), it's easier. Since this is common, we optimize for it. infls = {} local saw_semicolon = false for _, infl in ipairs(args[tagsind]) do if infl == ";" then saw_semicolon = true break end end local split_preinfl = split_inflection_tags(iargs.preinfl, iargs.split_tags) local split_postinfl = split_inflection_tags(iargs.postinfl, iargs.split_tags) if not saw_semicolon then extend(infls, split_preinfl) extend(infls, args[tagsind]) extend(infls, split_postinfl) else local groups = split_tag_set(args[tagsind]) for _, group in ipairs(groups) do if #infls > 0 then insert(infls, ";") end extend(infls, split_preinfl) extend(infls, group) extend(infls, split_postinfl) end end end return infls end, } end --[==[ Normalize a part-of-speech tag given a possible abbreviation (passed in as {{para|1}} of the invocation args). If the abbreviation isn't recognized, the original POS tag is returned. If no POS tag is passed in, return the value of invocation arg {{para|default}}. ]==] function export.normalize_pos(frame) local iparams = { [1] = true, ["default"] = true, } local iargs = process_params(frame.args, iparams) if not iargs[1] and not iargs.default then error("Either 1= or default= must be given in the invocation args") end if not iargs[1] then return iargs.default end return (m_form_of_pos or get_m_form_of_pos())[iargs[1]] or iargs[1] end return export 6zztzbvgvzw2t11ymi4qm7f6hdfjkbj 238969 238968 2026-11-14T02:55:54Z Lee 19 [[:en:Module:form_of/templates]] වෙතින් එක් සංශෝධනයක් 238968 Scribunto text/plain local export = {} local debug_track_module = "Module:debug/track" local form_of_module = "Module:form of" local functions_module = "Module:fun" local headword_data_module = "Module:headword/data" local languages_module = "Module:languages" local load_module = "Module:load" local parameters_module = "Module:parameters" local parameter_utilities_module = "Module:parameter utilities" local parse_interface_module = "Module:parse interface" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local utilities_module = "Module:utilities" local insert = table.insert local ipairs = ipairs local pairs = pairs local require = require local boolean_param = {type = "boolean"} -- FIXME: Finish [[Module:format utilities]]. -- local allowed_conj_set = require(format_utilities_module).allowed_conj_set_for_join_segments local allowed_conj_set = {["and"] = true, ["or"] = true, ["and/or"] = true} --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function decode_entities(...) decode_entities = require(string_utilities_module).decode_entities return decode_entities(...) end local function extend(...) extend = require(table_module).extend return extend(...) end local function format_categories(...) format_categories = require(utilities_module).format_categories return format_categories(...) end local function format_form_of(...) format_form_of = require(form_of_module).format_form_of return format_form_of(...) end local function get_lang(...) get_lang = require(languages_module).getByCode return get_lang(...) end local function gsplit(...) gsplit = require(string_utilities_module).gsplit return gsplit(...) end local function is_callable(...) is_callable = require(functions_module).is_callable return is_callable(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function parse_inline_modifiers(...) parse_inline_modifiers = require(parse_interface_module).parse_inline_modifiers return parse_inline_modifiers(...) end local function pattern_escape(...) pattern_escape = require(string_utilities_module).pattern_escape return pattern_escape(...) end local function process_params(...) process_params = require(parameters_module).process return process_params(...) end local function safe_load_data(...) safe_load_data = require(load_module).safe_load_data return safe_load_data(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function split_tag_set(...) split_tag_set = require(form_of_module).split_tag_set return split_tag_set(...) end local function tagged_inflections(...) tagged_inflections = require(form_of_module).tagged_inflections return tagged_inflections(...) end local function trim(...) trim = require(string_utilities_module).trim return trim(...) end local function ucfirst(...) ucfirst = require(string_utilities_module).ucfirst return ucfirst(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local force_cat local function get_force_cat() force_cat, get_force_cat = require(form_of_module).force_cat, nil return force_cat end local m_form_of_pos local function get_m_form_of_pos() m_form_of_pos, get_m_form_of_pos = load_data(headword_data_module).pos_aliases, nil return m_form_of_pos end local module_prefix local function get_module_prefix() module_prefix, get_module_prefix = require(form_of_module).form_of_lang_data_module_prefix, nil return module_prefix end --[==[ intro: This module contains code that directly implements {{tl|form of}}, {{tl|inflection of}}, and the various other [[:Category:Form-of templates|form-of templates]]. It is meant to be called directly from templates. See also [[Module:form of]], which contains the underlying implementing code and is meant to be called from other modules. ]==] -- Add tracking category for PAGE when called from TEMPLATE. The tracking category linked to is -- [[Wiktionary:Tracking/form of/TEMPLATE/PAGE]]. If TEMPLATE is omitted, the tracking category is of the form -- [[Wiktionary:Tracking/form of/PAGE]]. local function track(page, template) debug_track("form of/" .. (template and template .. "/" or "") .. page) end local function get_common_template_params() return { -- Named params not controlling link display ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, ["notext"] = boolean_param, ["sort"] = true, ["enclitic"] = true, -- FIXME! The following should only be available when withcap=1 in invocation args or when withencap=1 and the -- language is "en". Before doing that, need to remove all uses of nocap= in other circumstances. ["nocap"] = boolean_param, ["addl"] = true, -- additional text to display at the end, before the closing </span> ["pagename"] = true, -- for testing, etc. } end -- Split TAGSPECS (inflection tag specifications) on SPLIT_REGEX, which -- may be nil for no splitting. local function split_inflection_tags(tagspecs, split_regex) if not split_regex then return tagspecs end local inflection_tags = {} for _, tagspec in ipairs(tagspecs) do for tag in gsplit(tagspec, split_regex) do insert(inflection_tags, tag) end end return inflection_tags end local function parse_terms_with_inline_modifiers(paramname, val, param_mods, lang) local function generate_obj(term) return {lang = lang, term = decode_entities(term)} end return parse_inline_modifiers(val, { paramname = paramname, param_mods = param_mods, generate_obj = generate_obj, splitchar = ",", outer_container = {}, }) end -- Need to do what [[Module:parameters]] does to string arguments from parent_args as we're running this -- before calling [[Module:parameters]] on parent_args. local function ine(arg) if not arg then return nil end arg = trim(arg) return arg ~= "" and arg or nil end local function add_base_lemma_params(parent_args, iargs, params, compat) -- Check the language-specific data for additional base lemma params. But if there's no language-specific data, -- attempt any parent varieties as well (i.e. superordinate varieties). local lang = get_lang(ine(parent_args[compat and "lang" or 1]) or ine(iargs.lang) or "und", nil, true) while lang do local langdata = safe_load_data((module_prefix or get_module_prefix()) .. lang:getCode()) if langdata then local base_lemma_params = langdata.base_lemma_params if base_lemma_params then for _, param in ipairs(base_lemma_params) do params[param.param] = true end return base_lemma_params end end lang = lang:getParent() end end --[=[ Modify `params` in-place by adding parameters that control the link to the main entry and any base lemmas. `term_param` is the number of the param specifying the main entry itself; `term_param` + 1 will be the display text, and `term_param` + 2 will be the gloss, unless `no_numbered_gloss` is given. The base lemma parameters are determined by attempting to load language-specific data for the language of the page; this comes from |lang= if `compat` is given, else from |1=. ]=] local function add_link_and_base_lemma_params(iargs, parent_args, params, term_param, compat, no_numbered_gloss) local base_lemma_params if not iargs.nolink and not iargs.linktext then -- Numbered params controlling link display if iargs.with_multiple_parts then params[term_param] = {list = true, allow_holes = true} else params[term_param + 1] = {alias_of = "alt"} if not no_numbered_gloss then params[term_param + 2] = {alias_of = "t"} end params[term_param] = true end base_lemma_params = add_base_lemma_params(parent_args, iargs, params, compat) end return base_lemma_params end local function handle_withdot_withcap(iargs, params) local ignored_tracked_params = {} if iargs.withdot then params.dot = true params.nodot = boolean_param end if iargs.withcap and iargs.withencap then error("Internal error: Can specify only one of withcap= and withencap=") end if not iargs.withcap then params.cap = boolean_param ignored_tracked_params.nocap = iargs.withencap and "non-english" or "always" end return ignored_tracked_params end --[=[ Construct and return the full definition line for a form-of-type template invocation. `data` is an object with the following fields: * `template`: Approximate template name, for debug tracking; * `iargs`: processed invocation arguments; * `parent_args`: raw parent args from `frame:getParent().args`; * `params`: partially constructed params structure of the sort passed to `process()` in [[Module:parameters]], but without any link params; * `ignored_tracked_params`: params that are ignored but should be tracked, to be eventually removed; * `term_param`: the parent argument specifying the main entry; * `compat`: true if the language code is found in args.lang instead of args[1]; * `base_lemma_params`: if non-nil, a list of base lemma param objects of the sort stored in the language-specific data; * `do_form_of`: a function of one argument, `lemma_data`, that returns the actual definition-line text and any language-specific categories. See below. This function does several things: # If link parameters are called for (neither `iargs.nolink` nor `iargs.linktext` are given), augment the `params` structure with separate link parameters. # Modify the parent args as appropriate if invocation arguments def= or ignore= are given. # Parse the parent args, both for separate parameter properties and inline modifiers on the term parameter (which may consist of multiple comma-separated terms). # Compute categories to add to the page, including language-specific categories and any categories requested by the invocation or parent args. # Parse enclitic and extra base lemma parameters. # Construct the actual text using `do_form_of`. # Add a terminating period/dot as appropriate, along with the formatted categories. `do_form_of` takes one argument, `lemma_data`, which looks like this: { lang = LANG, args = {ARG = VALUE, ARG = VALUE, ...}, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, enclitics = {ENCLITIC_OBJ, ENCLITIC_OBJ, ...}, base_lemmas = {BASE_LEMMA_OBJ, BASE_LEMMA_OBJ, ...}, categories = {"CATEGORY", "CATEGORY", ...}, posttext = "POSTTEXT" or nil, } where * LANG is the language code; * ARGS is the parsed arguments, based on what the user specified; * LEMMAS is a sequence of objects specifying the main entries/lemmas, as passed to full_link in [[Module:links]]; however, if the invocation argument linktext= is given, it will be a string consisting of that text, and if the invocation argument nolink= is given, it will be nil; * ENCLITICS is nil or a sequence of objects specifying the enclitics, as passed to full_link in [[Module:links]]; * BASE_LEMMA_OBJ is a sequence of objects specifying the base lemma(s), which are used when the lemma is itself a form of another lemma (the base lemma), e.g. a comparative, superlative or participle; each object is of the form { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...} } where PARAM_OBJ describes the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas) and LEMMA_OBJ is of the same format of ENCLITIC_OBJ, i.e. an object suitable to be passed to full_link in [[Module:links]]; PARAM_OBJ is of the format { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{inflection of}} etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as {"comd"} or {"past", "part"}; * CATEGORIES is the categories to add the page to (consisting of any categories specified in the invocation or parent args and any tracking categories, but not any additional lang-specific categories that may be added by {{inflection of}} or similar templates); * POSTTEXT is text to display at the end of the form-of text, before the final </span> (or at the end of the first line, before the colon, in a multiline {{infl of}} call). `do_form_of` should return two arguments: (1) The actual definition-line text, marked up appropriately with <span>...</span> but without any terminating period/dot. (2) Any extra categories to add the page to (other than those that can be derived from parameters specified to the invocation or parent arguments, which will automatically be added to the page). ]=] local function construct_form_of_text(data) local template, iargs, parent_args, params, no_numbered_gloss, do_form_of = data.template, data.iargs, data.parent_args, data.params, data.no_numbered_gloss, data.do_form_of local term_param = iargs.term_param local compat = iargs.lang or parent_args.lang term_param = term_param or compat and 1 or 2 -- Numbered params params[compat and "lang" or 1] = { required = not iargs.lang, type = "language", default = iargs.lang or "und" } -- Error to catch most uses of old-style parameters for {{contraction of}}. (FIXME: Remove eventually.) if iargs.with_multiple_parts then if ine(parent_args[term_param + 2]) and not ine(parent_args[term_param + 1]) and not ine(parent_args.tr2) and not ine(parent_args.ts2) and not ine(parent_args.t2) and not ine(parent_args.gloss2) and not ine(parent_args.g2) and not ine(parent_args.alt2) then error(("You specified a term in %s= and not one in %s=. You probably meant to use t= to specify a gloss instead. " .. "If you intended to specify two terms, put the second term in %s=."):format(term_param + 2, term_param + 1, term_param + 1)) end if not ine(parent_args[term_param + 1]) and not ine(parent_args.alt2) and not ine(parent_args.tr2) and not ine(parent_args.ts2) and ine(parent_args.g2) then error(("You specified a gender in g2= but no term in %s=. You were probably trying to specify two genders for " .. "a single term. To do that, put both genders in g=, comma-separated."):format(term_param + 1)) end end local base_lemma_params = add_link_and_base_lemma_params(iargs, parent_args, params, term_param, compat, no_numbered_gloss) local ignored_tracked_params = handle_withdot_withcap(iargs, params) --[=[ Process parent arguments. This is similar to the following: require("Module:parameters").process(parent_args, params) but in addition it does the following: (1) Supplies default values for unspecified parent arguments as specified in DEFAULTS, which consist of specs of the form "ARG=VALUE". These are added to the parent arguments prior to processing, so boolean and number parameters will process the value appropriately. (2) Removes parent arguments specified in IGNORESPECS, which consist either of bare argument names to remove, or list-argument names to remove of the form "ARG:list". (3) Tracks the use of any parent arguments specified in TRACKED_PARAMS, which is a set where the keys are arguments as they exist after processing (hence numeric arguments should be numbers, not strings) and the values should be boolean true. ]=]-- local defaults = iargs.def local ignorespecs = iargs.ignore if defaults[1] or ignorespecs[1] then local new_parent_args = {} for _, default in ipairs(defaults) do local defparam, defval = default:match("^(.-)=(.*)$") if not defparam then error("Bad default spec " .. default) end new_parent_args[defparam] = defval end local params_to_ignore = {} local numbered_list_params_to_ignore = {} local named_list_params_to_ignore = {} for _, ignorespec in ipairs(ignorespecs) do for ignore in gsplit(ignorespec, ",") do local param = ignore:match("^(.*):list$") if param then if param:match("^%d+$") then insert(numbered_list_params_to_ignore, tonumber(param)) else insert(named_list_params_to_ignore, "^" .. pattern_escape(param) .. "%d*$") end else if ignore:match("^%d+$") then ignore = tonumber(ignore) end params_to_ignore[ignore] = true end end end for k, v in pairs(parent_args) do if not params_to_ignore[k] then local ignore_me = false if type(k) == "number" then for _, lparam in ipairs(numbered_list_params_to_ignore) do if k >= lparam then ignore_me = true break end end else for _, lparam in ipairs(named_list_params_to_ignore) do if k:match(lparam) then ignore_me = true break end end end if not ignore_me then new_parent_args[k] = v end end end parent_args = new_parent_args end local param_mods_with_conj, param_mods_without_conj local function get_param_mods(with_conj) if with_conj then if not param_mods_with_conj then param_mods_with_conj = require(parameter_utilities_module).construct_param_mods { {group = {"link", "q", "l", "ref"}}, {param = "conj", set = allowed_conj_set, overall = true}, } end return param_mods_with_conj else if not param_mods_without_conj then param_mods_without_conj = require(parameter_utilities_module).construct_param_mods { {group = {"link", "q", "l", "ref"}}, -- Override lit= to have a separate overall value {param = "lit", separate_no_index = true}, } end return param_mods_without_conj end end local terms, args if iargs.nolink or iargs.linktext then args = process_params(parent_args, params) else local m_param_utils = require(parameter_utilities_module) if iargs.with_multiple_parts then terms, args = m_param_utils.parse_list_with_inline_modifiers_and_separate_params { params = params, param_mods = get_param_mods(false), raw_args = parent_args, termarg = term_param, track_module = "form of" .. (template and "/" .. template or ""), lang = compat and "lang" or 1, sc = "sc.default", parse_lang_prefix = true, default_separator = " +&lrm; ", special_separators = {[";"] = " or "}, } else terms, args = m_param_utils.parse_term_with_inline_modifiers_and_separate_params { params = params, param_mods = get_param_mods("with conj"), raw_args = parent_args, termarg = term_param, track_module = "form of" .. (template and "/" .. template or ""), lang = compat and "lang" or 1, sc = "sc", parse_lang_prefix = true, make_separate_g_into_list = true, splitchar = ",", subitem_param_handling = "last", } end end local lang = args[compat and "lang" or 1] -- Tracking for certain user-specified params. This is generally used for -- parameters that we accept but ignore, so that we can eventually remove -- all uses of these params and stop accepting them. if ignored_tracked_params then for ignored_tracked_param, condition in pairs(ignored_tracked_params) do if parent_args[ignored_tracked_param] and (condition ~= "non-english" or lang:getCode() ~= "en") then track("arg/" .. ignored_tracked_param, template) track("arg/" .. ignored_tracked_param) end end end -- Determine categories for the page, including tracking categories local categories = {} if not args.nocat then for _, cat in ipairs(iargs.cat) do insert(categories, lang:getFullName() .. " " .. cat) end end for _, cat in ipairs(args.cat) do insert(categories, lang:getFullName() .. " " .. cat) end -- Format the link, preceding text and categories local function add_term_tracking_categories(term) local term_title = lang:stripDiacritics(term) -- add tracking category if term is same as page title if term_title and mw.loadData("Module:headword/data").pagename == term_title then insert(categories, "Forms linking to themselves") end -- maybe add tracking category if primary entry doesn't exist (this is an -- expensive call so we don't do it by default) if iargs.noprimaryentrycat and term_title and mw.title.getCurrentTitle().nsText == "" and not mw.title.new(term_title):getContent() then insert(categories, lang:getFullName() .. " " .. iargs.noprimaryentrycat) end end local lemmas if iargs.nolink then lemmas = nil elseif iargs.linktext then lemmas = iargs.linktext else if iargs.with_multiple_parts then lemmas = terms else lemmas = terms.terms end if not lemmas[1] then if mw.title.getCurrentTitle().nsText == "Template" then lemmas[1] = { lang = lang, term = "term" } else error("No linked-to term specified") end end for _, termobj in ipairs(lemmas) do if termobj.term then add_term_tracking_categories(termobj.term) end -- NOTE: Formerly, template arg sc= overrode inline modifier <sc:...>, which seems backwards, so I've -- changed it. Hopefully nothing depended on the old behavior. end end local enclitics, enclitic_conj if args.enclitic then local enclitics_obj = parse_terms_with_inline_modifiers("enclitic", args.enclitic, get_param_mods("with conj"), lang) enclitics = enclitics_obj.terms enclitic_conj = enclitics_obj.conj end local base_lemmas = {} if base_lemma_params then for _, base_lemma_param_obj in ipairs(base_lemma_params) do local param = base_lemma_param_obj.param if args[param] then local base_lemmas_obj = parse_terms_with_inline_modifiers(param, args[param], get_param_mods("with conj"), lang) insert(base_lemmas, { paramobj = base_lemma_param_obj, lemmas = base_lemmas_obj.terms, conj = base_lemmas_obj.conj, }) end end end local posttext = iargs.posttext local addl = args.addl if addl then posttext = posttext or "" if addl:find("^[;:]") then posttext = posttext .. addl elseif addl:find("^_") then posttext = posttext .. " " .. addl:sub(2) else posttext = posttext .. ", " .. addl end end local conj if iargs.with_multiple_parts then conj = false -- signals to use 'separator' field else conj = terms and terms.conj or iargs.conj end local lemma_data = { lang = lang, args = args, lemmas = lemmas, conj = conj, enclitics = enclitics, enclitic_conj = enclitic_conj, base_lemmas = base_lemmas, categories = categories, posttext = posttext, lit = iargs.with_multiple_parts and args.lit.default or nil, } local form_of_text, lang_cats = do_form_of(lemma_data) extend(lemma_data.categories, lang_cats) local text = form_of_text .. ( args.nodot and "" or args.dot or iargs.withdot and "." or "" ) if not lemma_data.categories[1] then return text end return text .. format_categories(lemma_data.categories, lemma_data.lang, args.sort, -- If lemma_is_sort_key is given, supply the first lemma term as the sort base if possible. If sort= is given, -- it will override the base; otherwise, the base will be converted appropriately to a sort key using the -- same algorithm applied to pagenames. iargs.lemma_is_sort_key and type(lemma_data.lemmas) == "table" and lemma_data.lemmas[1].term, -- Supply the first lemma's script for sort key computation. force_cat or get_force_cat(), type(lemma_data.lemmas) == "table" and lemma_data.lemmas[1].sc) end -- Invocation parameters shared between form_of_t(), tagged_form_of_t() and inflection_of_t(). `calling_func` is the -- invoking function ("form_of_t", "tagged_form_of_t" or "inflection_of_t"), for handling parameters shared by two but -- not all three invoking functions. local function get_common_invocation_params(calling_func) local iparams = { ["term_param"] = {type = "number"}, ["lang"] = true, -- To be used as the default code in params. ["sc"] = {type = "script"}, ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, ["ignore"] = {list = true}, ["def"] = {list = true}, ["conj"] = {set = allowed_conj_set, default = "and"}, ["withcap"] = boolean_param, ["withencap"] = boolean_param, ["withdot"] = boolean_param, ["nolink"] = boolean_param, ["linktext"] = true, ["posttext"] = true, ["noprimaryentrycat"] = true, ["lemma_is_sort_key"] = true, } if calling_func ~= "inflection_of_t" then iparams.with_multiple_parts = boolean_param end return iparams end local function should_ucfirst_text(args, iargs, lang) local code = lang:getCode() return args.cap or (iargs.withcap or iargs.withencap and code == "en" or code == "mul") and not args.nocap end --[==[ Function that implements {{tl|form of}} and the various more specific form-of templates (but not {{tl|inflection of}} or templates that take tagged inflection parameters). Invocation params: ; {{para|1|req=1}} : Text to display before the link. ; {{para|term_param}} : Numbered param holding the term linked to. Other numbered params come after. Defaults to 1 if invocation or template param {{para|lang}} is present, otherwise 2. ; {{para|with_multiple_parts|1}} : If specified, higher numbered parameters above the numbered param in {{para|term_param}} specify additional parts out of which the term was constructed, for use by templates like {{tl|contraction of}}. (If not specified, the parameter at <code><var>term_param</var> + 1</code> is the display form, same as {{para|alt}}, and the parameter at at <code><var>term_param</var> + 2</code> is the gloss, same as {{para|t}}.) ; {{para|lang}} : Default language code for language-specific templates. If specified, no language code needs to be specified, and if specified it needs to be set using {{para|lang}}, not {{para|1}}. ; {{para|sc}} : Default script code for language-specific templates. The script code can still be overridden using template param {{para|sc}}. ; {{para|cat}}, {{para|cat2}}, ...: : Categories to place the page into. The language name will automatically be prepended. Note that there is also a template param {{para|cat}} to specify categories at the template level. Use of {{para|nocat}} disables categorization of categories specified using invocation param {{para|cat}}, but not using template param {{para|cat}}. A single param can specify multiple comma-separated categories if no space follows the comma. ; {{para|ignore}}, {{para|ignore2}}, ...: : One or more template params to silently accept and ignore. Useful e.g. when the template takes additional parameters such as {{para|from}} or {{para|POS}}. Each value is a comma-separated list of either bare parameter names or specifications of the form `PARAM:list` to specify that the parameter is a list parameter. ; {{para|def}}, {{para|def2}}, ...: : One or more default values to supply for template args. For example, specifying {{para|def|2=tr=-}} causes the default for template param {{para|tr}} to be `-`. Actual template params override these defaults. ; {{para|withcap|1}} : Capitalize the first character of the text preceding the link, unless template param {{para|nocap}} is given. ; {{para|withencap|1}} : Capitalize the first character of the text preceding the link if the language is English and template param {{para|nocap}} is not given. ; {{para|withdot|1}} : Add a final period after the link, unless template param {{para|nodot}} is given to suppress the period, or {{para|dot}} is given to specify an alternative punctuation character. ; {{para|nolink|1}} : Suppress the display of the link. If specified, none of the template params that control the link ({{para|<var>term_param</var>}}, {{para|<var>term_param</var> + 1}}, {{para|<var>term_param</var> + 2}}, {{para|t}}, {{para|gloss}}, {{para|sc}}, {{para|tr}}, {{para|ts}}, {{para|pos}}, {{para|g}}, {{para|id}}, {{para|lit}}) will be available. If the calling template uses any of these parameters, they must be ignored using {{para|ignore}}. {{para|linktext}} : Override the display of the link with the specified text. This is useful if a custom template is available to format the link (e.g. in Hebrew, Chinese and Japanese). If specified, none of the template params that control the link ({{para|<var>term_param</var>}}, {{para|<var>term_param</var> + 1}}, {{para|<var>term_param</var> + 2}}, {{para|t}}, {{para|gloss}}, {{para|sc}}, {{para|tr}}, {{para|ts}}, {{para|pos}}, {{para|g}}, {{para|id}}, {{para|lit}}) will be available. If the calling template uses any of these parameters, they must be ignored using {{para|ignore}}. ; {{para|posttext}} : Additional text to display directly after the formatted link, before any terminating period/dot and inside of `<span class='use-with-mention'>`. ; {{para|noprimaryentrycat}} : Category to add the page to if the primary entry linked to doesn't exist. The language name will automatically be prepended. ; {{para|lemma_is_sort_key|1}} : If the user didn't specify a sort key, use the lemma as the sort key (instead of the page itself). ]==] function export.form_of_t(frame) local iparams = get_common_invocation_params("form_of_t") iparams[1] = {required = true} local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() if next(iargs.cat) then params.nocat = boolean_param end return construct_form_of_text { template = "form-of-t", iargs = iargs, parent_args = parent_args, params = params, do_form_of = function(lemma_data) local args = lemma_data.args local text if args.notext then text = "" else text = iargs[1] if should_ucfirst_text(args, iargs, lemma_data.lang) then text = ucfirst(text) end end -- This returns two values, which we pass up to the caller. return format_form_of { lang = lemma_data.lang, text = text, lemmas = lemma_data.lemmas, conj = lemma_data.conj, enclitics = lemma_data.enclitics, base_lemmas = lemma_data.base_lemmas, lemma_face = "term", lit = lemma_data.lit, posttext = lemma_data.posttext } end } end --[=[ Construct and return the full definition line for a form-of-type template invocation that is based on inflection tags. This is a wrapper around construct_form_of_text() and takes the following arguments: processed invocation arguments IARGS, processed parent arguments ARGS, TERM_PARAM (the parent argument specifying the main entry), COMPAT (true if the language code is found in args.lang instead of args[1]), and TAGS, the list of (non-canonicalized) inflection tags. It returns that actual definition-line text including terminating period/full-stop, formatted categories, etc. and should be directly returned as the template function's return value. ]=] local function construct_tagged_form_of_text(data) local template, iargs, parent_args, params, no_numbered_gloss, tags = data.template, data.iargs, data.parent_args, data.params, data.no_numbered_gloss, data.tags -- Named params not controlling link display -- Always included because lang-specific categories may be added params.nocat = boolean_param params.p = true params.POS = {alias_of = "p"} return construct_form_of_text { template = template, iargs = iargs, parent_args = parent_args, params = params, no_numbered_gloss = no_numbered_gloss, do_form_of = function(lemma_data) local args = lemma_data.args if is_callable(tags) then tags = tags(args) end -- NOTE: tagged_inflections returns two values, so we do too. return tagged_inflections { lang = lemma_data.lang, tags = tags, lemmas = lemma_data.lemmas, conj = lemma_data.conj, enclitics = lemma_data.enclitics, enclitic_conj = lemma_data.enclitic_conj, base_lemmas = lemma_data.base_lemmas, lemma_face = "term", POS = args.p, pagename = args.pagename, -- Set no_format_categories because we do it ourselves in construct_form_of_text(). no_format_categories = true, nocat = args.nocat, notext = args.notext, capfirst = should_ucfirst_text(args, iargs, lemma_data.lang), posttext = lemma_data.posttext, } end } end --[==[ Function that implements form-of templates that are defined by specific tagged inflections (typically a template referring to a non-lemma inflection, such as {{tl|plural of}}). This works exactly like {form_of_t()} except that the "form of" text displayed before the link is based off of a pre-specified set of inflection tags (which will be appropriately linked to the glossary) instead of arbitrary text. From the user's perspective, there is no difference between templates implemented using {form_of_t()} and {tagged_form_of_t()}; they accept exactly the same parameters and work the same. See also {inflection_of_t()} below, which is intended for templates with user-specified inflection tags. Invocation params: ; {{para|1|req=1}}, {{para|2}}, ... : One or more inflection tags describing the inflection in question. ; {{para|split_tags}} : If specified, character to split specified inflection tags on. This allows multiple tags to be included in a single argument, simplifying template code. ; {{para|term_param}} ; {{para|with_multiple_parts|1}} ; {{para|lang}} ; {{para|sc}} ; {{para|cat}}, {{para|cat2}}, ... ; {{para|ignore}}, {{para|ignore2}}, ... ; {{para|def}}, {{para|def2}}, ... ; {{para|withcap|1}} ; {{para|withencap|1}} ; {{para|withdot|1}} ; {{para|nolink|1}} ; {{para|linktext}} ; {{para|posttext}} ; {{para|noprimaryentrycat}} ; {{para|lemma_is_sort_key|1}} : All of these are the same as in {form_of_t()}. ]==] function export.tagged_form_of_t(frame) local iparams = get_common_invocation_params("tagged_form_of_t") iparams[1] = {list = true, required = true} iparams.split_tags = true local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() return construct_tagged_form_of_text { template = "tagged-form-of-t", iargs = iargs, parent_args = parent_args, params = params, tags = split_inflection_tags(iargs[1], iargs.split_tags), } end --[==[ Function that implements {{tl|inflection of}} and certain semi-specific variants, such as {{tl|participle of}} and {{tl|past participle form of}}. This function is intended for templates that allow the user to specify a set of inflection tags. It works similarly to {form_of_t()} and {tagged_form_of_t()} except that the calling convention for the calling template is : { {{TEMPLATE|LANG|MAIN_ENTRY_LINK|MAIN_ENTRY_DISPLAY_TEXT|TAG|TAG|...}}} instead of : { {{TEMPLATE|LANG|MAIN_ENTRY_LINK|MAIN_ENTRY_DISPLAY_TEXT|GLOSS}}} Note that there isn't a numbered parameter for the gloss, but it can still be specified using {{para|t}} or {{para|gloss}}. Invocation params: ; {{para|preinfl}}, {{para|preinfl2}}, ... : Extra inflection tags to automatically prepend to the tags specified by the template. ; {{para|postinfl}}, {{para|postinfl2}}, ... : Extra inflection tags to automatically append to the tags specified by the template. Used for example by {{tl|past participle form of}} to add the tags `of the|past|p` onto the user-specified tags, which indicate which past participle form the page refers to. ; {{para|split_tags}} : If specified, character to split specified inflection tags on. This allows multiple tags to be included in a single argument, simplifying template code. Note that this applies *ONLY* to inflection tags specified in the invocation arguments using {{para|preinfl}} or {{para|postinfl}}, not to user-specified inflection tags. ; {{para|term_param}} ; {{para|lang}} ; {{para|sc}} ; {{para|cat}}, {{para|cat2}}, ... ; {{para|ignore}}, {{para|ignore2}}, ... ; {{para|def}}, {{para|def2}}, ... ; {{para|withcap|1}} ; {{para|withencap|1}} ; {{para|withdot|1}} ; {{para|nolink|1}} ; {{para|linktext}} ; {{para|posttext}} ; {{para|noprimaryentrycat}} ; {{para|lemma_is_sort_key|1}} : All of these are the same as in {form_of_t()}. ]==] function export.inflection_of_t(frame) local iparams = get_common_invocation_params("inflection_of_t") iparams.preinfl = {list = true} iparams.postinfl = {list = true} iparams.split_tags = true local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() local compat = iargs.lang or parent_args.lang local tagsind = (iargs.term_param or compat and 1 or 2) + 2 params[tagsind] = {list = true, -- at least one inflection tag is required unless preinfl or postinfl tags are given required = #iargs.preinfl == 0 and #iargs.postinfl == 0} return construct_tagged_form_of_text { template = "inflection-of-t", iargs = iargs, parent_args = parent_args, params = params, no_numbered_gloss = true, tags = function(args) local infls if not next(iargs.preinfl) and not next(iargs.postinfl) then -- If no preinfl or postinfl tags, just use the user-specified tags directly. infls = args[tagsind] else -- Otherwise, we need to prepend the preinfl tags and postpend the postinfl tags. If there's only one tag set -- (no semicolon), it's easier. Since this is common, we optimize for it. infls = {} local saw_semicolon = false for _, infl in ipairs(args[tagsind]) do if infl == ";" then saw_semicolon = true break end end local split_preinfl = split_inflection_tags(iargs.preinfl, iargs.split_tags) local split_postinfl = split_inflection_tags(iargs.postinfl, iargs.split_tags) if not saw_semicolon then extend(infls, split_preinfl) extend(infls, args[tagsind]) extend(infls, split_postinfl) else local groups = split_tag_set(args[tagsind]) for _, group in ipairs(groups) do if #infls > 0 then insert(infls, ";") end extend(infls, split_preinfl) extend(infls, group) extend(infls, split_postinfl) end end end return infls end, } end --[==[ Normalize a part-of-speech tag given a possible abbreviation (passed in as {{para|1}} of the invocation args). If the abbreviation isn't recognized, the original POS tag is returned. If no POS tag is passed in, return the value of invocation arg {{para|default}}. ]==] function export.normalize_pos(frame) local iparams = { [1] = true, ["default"] = true, } local iargs = process_params(frame.args, iparams) if not iargs[1] and not iargs.default then error("Either 1= or default= must be given in the invocation args") end if not iargs[1] then return iargs.default end return (m_form_of_pos or get_m_form_of_pos())[iargs[1]] or iargs[1] end return export 6zztzbvgvzw2t11ymi4qm7f6hdfjkbj 238972 238969 2026-11-14T02:56:21Z Lee 19 පැරණි සංස්කරණයකින් ගත් කොටස්... 238972 Scribunto text/plain local m_sinhala = require("Module:sinhala") local export = {} local debug_track_module = "Module:debug/track" local form_of_module = "Module:form of" local functions_module = "Module:fun" local headword_data_module = "Module:headword/data" local languages_module = "Module:languages" local load_module = "Module:load" local parameters_module = "Module:parameters" local parameter_utilities_module = "Module:parameter utilities" local parse_interface_module = "Module:parse interface" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local utilities_module = "Module:utilities" local insert = table.insert local ipairs = ipairs local pairs = pairs local require = require local boolean_param = {type = "boolean"} -- FIXME: Finish [[Module:format utilities]]. -- local allowed_conj_set = require(format_utilities_module).allowed_conj_set_for_join_segments local allowed_conj_set = {["and"] = true, ["or"] = true, ["and/or"] = true} --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function decode_entities(...) decode_entities = require(string_utilities_module).decode_entities return decode_entities(...) end local function extend(...) extend = require(table_module).extend return extend(...) end local function format_categories(...) format_categories = require(utilities_module).format_categories return format_categories(...) end local function format_form_of(...) format_form_of = require(form_of_module).format_form_of return format_form_of(...) end local function get_lang(...) get_lang = require(languages_module).getByCode return get_lang(...) end local function gsplit(...) gsplit = require(string_utilities_module).gsplit return gsplit(...) end local function is_callable(...) is_callable = require(functions_module).is_callable return is_callable(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function parse_inline_modifiers(...) parse_inline_modifiers = require(parse_interface_module).parse_inline_modifiers return parse_inline_modifiers(...) end local function pattern_escape(...) pattern_escape = require(string_utilities_module).pattern_escape return pattern_escape(...) end local function process_params(...) process_params = require(parameters_module).process return process_params(...) end local function safe_load_data(...) safe_load_data = require(load_module).safe_load_data return safe_load_data(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function split_tag_set(...) split_tag_set = require(form_of_module).split_tag_set return split_tag_set(...) end local function tagged_inflections(...) tagged_inflections = require(form_of_module).tagged_inflections return tagged_inflections(...) end local function trim(...) trim = require(string_utilities_module).trim return trim(...) end local function ucfirst(...) ucfirst = require(string_utilities_module).ucfirst return ucfirst(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local force_cat local function get_force_cat() force_cat, get_force_cat = require(form_of_module).force_cat, nil return force_cat end local m_form_of_pos local function get_m_form_of_pos() m_form_of_pos, get_m_form_of_pos = load_data(headword_data_module).pos_aliases, nil return m_form_of_pos end local module_prefix local function get_module_prefix() module_prefix, get_module_prefix = require(form_of_module).form_of_lang_data_module_prefix, nil return module_prefix end --[==[ intro: This module contains code that directly implements {{tl|form of}}, {{tl|inflection of}}, and the various other [[:Category:Form-of templates|form-of templates]]. It is meant to be called directly from templates. See also [[Module:form of]], which contains the underlying implementing code and is meant to be called from other modules. ]==] -- Add tracking category for PAGE when called from TEMPLATE. The tracking category linked to is -- [[Wiktionary:Tracking/form of/TEMPLATE/PAGE]]. If TEMPLATE is omitted, the tracking category is of the form -- [[Wiktionary:Tracking/form of/PAGE]]. local function track(page, template) debug_track("form of/" .. (template and template .. "/" or "") .. page) end local function get_common_template_params() return { -- Named params not controlling link display ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, ["notext"] = boolean_param, ["sort"] = true, ["enclitic"] = true, -- FIXME! The following should only be available when withcap=1 in invocation args or when withencap=1 and the -- language is "en". Before doing that, need to remove all uses of nocap= in other circumstances. ["nocap"] = boolean_param, ["addl"] = true, -- additional text to display at the end, before the closing </span> ["pagename"] = true, -- for testing, etc. } end -- Split TAGSPECS (inflection tag specifications) on SPLIT_REGEX, which -- may be nil for no splitting. local function split_inflection_tags(tagspecs, split_regex) if not split_regex then return tagspecs end local inflection_tags = {} for _, tagspec in ipairs(tagspecs) do for tag in gsplit(tagspec, split_regex) do insert(inflection_tags, tag) end end return inflection_tags end local function parse_terms_with_inline_modifiers(paramname, val, param_mods, lang) local function generate_obj(term) return {lang = lang, term = decode_entities(term)} end return parse_inline_modifiers(val, { paramname = paramname, param_mods = param_mods, generate_obj = generate_obj, splitchar = ",", outer_container = {}, }) end -- Need to do what [[Module:parameters]] does to string arguments from parent_args as we're running this -- before calling [[Module:parameters]] on parent_args. local function ine(arg) if not arg then return nil end arg = trim(arg) return arg ~= "" and arg or nil end local function add_base_lemma_params(parent_args, iargs, params, compat) -- Check the language-specific data for additional base lemma params. But if there's no language-specific data, -- attempt any parent varieties as well (i.e. superordinate varieties). local lang = get_lang(ine(parent_args[compat and "lang" or 1]) or ine(iargs.lang) or "und", nil, true) while lang do local langdata = safe_load_data((module_prefix or get_module_prefix()) .. lang:getCode()) if langdata then local base_lemma_params = langdata.base_lemma_params if base_lemma_params then for _, param in ipairs(base_lemma_params) do params[param.param] = true end return base_lemma_params end end lang = lang:getParent() end end --[=[ Modify `params` in-place by adding parameters that control the link to the main entry and any base lemmas. `term_param` is the number of the param specifying the main entry itself; `term_param` + 1 will be the display text, and `term_param` + 2 will be the gloss, unless `no_numbered_gloss` is given. The base lemma parameters are determined by attempting to load language-specific data for the language of the page; this comes from |lang= if `compat` is given, else from |1=. ]=] local function add_link_and_base_lemma_params(iargs, parent_args, params, term_param, compat, no_numbered_gloss) local base_lemma_params if not iargs.nolink and not iargs.linktext then -- Numbered params controlling link display if iargs.with_multiple_parts then params[term_param] = {list = true, allow_holes = true} else params[term_param + 1] = {alias_of = "alt"} if not no_numbered_gloss then params[term_param + 2] = {alias_of = "t"} end params[term_param] = true end base_lemma_params = add_base_lemma_params(parent_args, iargs, params, compat) end return base_lemma_params end local function handle_withdot_withcap(iargs, params) local ignored_tracked_params = {} if iargs.withdot then params.dot = true params.nodot = boolean_param end if iargs.withcap and iargs.withencap then error("Internal error: Can specify only one of withcap= and withencap=") end if not iargs.withcap then params.cap = boolean_param ignored_tracked_params.nocap = iargs.withencap and "non-english" or "always" end return ignored_tracked_params end --[=[ Construct and return the full definition line for a form-of-type template invocation. `data` is an object with the following fields: * `template`: Approximate template name, for debug tracking; * `iargs`: processed invocation arguments; * `parent_args`: raw parent args from `frame:getParent().args`; * `params`: partially constructed params structure of the sort passed to `process()` in [[Module:parameters]], but without any link params; * `ignored_tracked_params`: params that are ignored but should be tracked, to be eventually removed; * `term_param`: the parent argument specifying the main entry; * `compat`: true if the language code is found in args.lang instead of args[1]; * `base_lemma_params`: if non-nil, a list of base lemma param objects of the sort stored in the language-specific data; * `do_form_of`: a function of one argument, `lemma_data`, that returns the actual definition-line text and any language-specific categories. See below. This function does several things: # If link parameters are called for (neither `iargs.nolink` nor `iargs.linktext` are given), augment the `params` structure with separate link parameters. # Modify the parent args as appropriate if invocation arguments def= or ignore= are given. # Parse the parent args, both for separate parameter properties and inline modifiers on the term parameter (which may consist of multiple comma-separated terms). # Compute categories to add to the page, including language-specific categories and any categories requested by the invocation or parent args. # Parse enclitic and extra base lemma parameters. # Construct the actual text using `do_form_of`. # Add a terminating period/dot as appropriate, along with the formatted categories. `do_form_of` takes one argument, `lemma_data`, which looks like this: { lang = LANG, args = {ARG = VALUE, ARG = VALUE, ...}, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...}, enclitics = {ENCLITIC_OBJ, ENCLITIC_OBJ, ...}, base_lemmas = {BASE_LEMMA_OBJ, BASE_LEMMA_OBJ, ...}, categories = {"CATEGORY", "CATEGORY", ...}, posttext = "POSTTEXT" or nil, } where * LANG is the language code; * ARGS is the parsed arguments, based on what the user specified; * LEMMAS is a sequence of objects specifying the main entries/lemmas, as passed to full_link in [[Module:links]]; however, if the invocation argument linktext= is given, it will be a string consisting of that text, and if the invocation argument nolink= is given, it will be nil; * ENCLITICS is nil or a sequence of objects specifying the enclitics, as passed to full_link in [[Module:links]]; * BASE_LEMMA_OBJ is a sequence of objects specifying the base lemma(s), which are used when the lemma is itself a form of another lemma (the base lemma), e.g. a comparative, superlative or participle; each object is of the form { paramobj = PARAM_OBJ, lemmas = {LEMMA_OBJ, LEMMA_OBJ, ...} } where PARAM_OBJ describes the properties of the base lemma parameter (i.e. the relationship between the intermediate and base lemmas) and LEMMA_OBJ is of the same format of ENCLITIC_OBJ, i.e. an object suitable to be passed to full_link in [[Module:links]]; PARAM_OBJ is of the format { param = "PARAM", tags = {"TAG", "TAG", ...} } where PARAM is the name of the parameter to {{inflection of}} etc. that holds the base lemma(s) of the specified relationship and the tags describe the relationship, such as {"comd"} or {"past", "part"}; * CATEGORIES is the categories to add the page to (consisting of any categories specified in the invocation or parent args and any tracking categories, but not any additional lang-specific categories that may be added by {{inflection of}} or similar templates); * POSTTEXT is text to display at the end of the form-of text, before the final </span> (or at the end of the first line, before the colon, in a multiline {{infl of}} call). `do_form_of` should return two arguments: (1) The actual definition-line text, marked up appropriately with <span>...</span> but without any terminating period/dot. (2) Any extra categories to add the page to (other than those that can be derived from parameters specified to the invocation or parent arguments, which will automatically be added to the page). ]=] local function construct_form_of_text(data) local template, iargs, parent_args, params, no_numbered_gloss, do_form_of = data.template, data.iargs, data.parent_args, data.params, data.no_numbered_gloss, data.do_form_of local term_param = iargs.term_param local compat = iargs.lang or parent_args.lang term_param = term_param or compat and 1 or 2 -- Numbered params params[compat and "lang" or 1] = { required = not iargs.lang, type = "language", default = iargs.lang or "und" } -- Error to catch most uses of old-style parameters for {{contraction of}}. (FIXME: Remove eventually.) if iargs.with_multiple_parts then if ine(parent_args[term_param + 2]) and not ine(parent_args[term_param + 1]) and not ine(parent_args.tr2) and not ine(parent_args.ts2) and not ine(parent_args.t2) and not ine(parent_args.gloss2) and not ine(parent_args.g2) and not ine(parent_args.alt2) then error(("You specified a term in %s= and not one in %s=. You probably meant to use t= to specify a gloss instead. " .. "If you intended to specify two terms, put the second term in %s=."):format(term_param + 2, term_param + 1, term_param + 1)) end if not ine(parent_args[term_param + 1]) and not ine(parent_args.alt2) and not ine(parent_args.tr2) and not ine(parent_args.ts2) and ine(parent_args.g2) then error(("You specified a gender in g2= but no term in %s=. You were probably trying to specify two genders for " .. "a single term. To do that, put both genders in g=, comma-separated."):format(term_param + 1)) end end local base_lemma_params = add_link_and_base_lemma_params(iargs, parent_args, params, term_param, compat, no_numbered_gloss) local ignored_tracked_params = handle_withdot_withcap(iargs, params) --[=[ Process parent arguments. This is similar to the following: require("Module:parameters").process(parent_args, params) but in addition it does the following: (1) Supplies default values for unspecified parent arguments as specified in DEFAULTS, which consist of specs of the form "ARG=VALUE". These are added to the parent arguments prior to processing, so boolean and number parameters will process the value appropriately. (2) Removes parent arguments specified in IGNORESPECS, which consist either of bare argument names to remove, or list-argument names to remove of the form "ARG:list". (3) Tracks the use of any parent arguments specified in TRACKED_PARAMS, which is a set where the keys are arguments as they exist after processing (hence numeric arguments should be numbers, not strings) and the values should be boolean true. ]=]-- local defaults = iargs.def local ignorespecs = iargs.ignore if defaults[1] or ignorespecs[1] then local new_parent_args = {} for _, default in ipairs(defaults) do local defparam, defval = default:match("^(.-)=(.*)$") if not defparam then error("Bad default spec " .. default) end new_parent_args[defparam] = defval end local params_to_ignore = {} local numbered_list_params_to_ignore = {} local named_list_params_to_ignore = {} for _, ignorespec in ipairs(ignorespecs) do for ignore in gsplit(ignorespec, ",") do local param = ignore:match("^(.*):list$") if param then if param:match("^%d+$") then insert(numbered_list_params_to_ignore, tonumber(param)) else insert(named_list_params_to_ignore, "^" .. pattern_escape(param) .. "%d*$") end else if ignore:match("^%d+$") then ignore = tonumber(ignore) end params_to_ignore[ignore] = true end end end for k, v in pairs(parent_args) do if not params_to_ignore[k] then local ignore_me = false if type(k) == "number" then for _, lparam in ipairs(numbered_list_params_to_ignore) do if k >= lparam then ignore_me = true break end end else for _, lparam in ipairs(named_list_params_to_ignore) do if k:match(lparam) then ignore_me = true break end end end if not ignore_me then new_parent_args[k] = v end end end parent_args = new_parent_args end local param_mods_with_conj, param_mods_without_conj local function get_param_mods(with_conj) if with_conj then if not param_mods_with_conj then param_mods_with_conj = require(parameter_utilities_module).construct_param_mods { {group = {"link", "q", "l", "ref"}}, {param = "conj", set = allowed_conj_set, overall = true}, } end return param_mods_with_conj else if not param_mods_without_conj then param_mods_without_conj = require(parameter_utilities_module).construct_param_mods { {group = {"link", "q", "l", "ref"}}, -- Override lit= to have a separate overall value {param = "lit", separate_no_index = true}, } end return param_mods_without_conj end end local terms, args if iargs.nolink or iargs.linktext then args = process_params(parent_args, params) else local m_param_utils = require(parameter_utilities_module) if iargs.with_multiple_parts then terms, args = m_param_utils.parse_list_with_inline_modifiers_and_separate_params { params = params, param_mods = get_param_mods(false), raw_args = parent_args, termarg = term_param, track_module = "form of" .. (template and "/" .. template or ""), lang = compat and "lang" or 1, sc = "sc.default", parse_lang_prefix = true, default_separator = " +&lrm; ", special_separators = {[";"] = " or "}, } else terms, args = m_param_utils.parse_term_with_inline_modifiers_and_separate_params { params = params, param_mods = get_param_mods("with conj"), raw_args = parent_args, termarg = term_param, track_module = "form of" .. (template and "/" .. template or ""), lang = compat and "lang" or 1, sc = "sc", parse_lang_prefix = true, make_separate_g_into_list = true, splitchar = ",", subitem_param_handling = "last", } end end local lang = args[compat and "lang" or 1] -- Tracking for certain user-specified params. This is generally used for -- parameters that we accept but ignore, so that we can eventually remove -- all uses of these params and stop accepting them. if ignored_tracked_params then for ignored_tracked_param, condition in pairs(ignored_tracked_params) do if parent_args[ignored_tracked_param] and (condition ~= "non-english" or lang:getCode() ~= "en") then track("arg/" .. ignored_tracked_param, template) track("arg/" .. ignored_tracked_param) end end end -- Determine categories for the page, including tracking categories local categories = {} if not args.nocat then for _, cat in ipairs(iargs.cat) do insert(categories, lang:getFullName() .. " " .. m_sinhala.sinhala(cat)) end end for _, cat in ipairs(args.cat) do insert(categories, lang:getFullName() .. " " .. m_sinhala.sinhala(cat)) end -- Format the link, preceding text and categories local function add_term_tracking_categories(term) local term_title = lang:stripDiacritics(term) -- add tracking category if term is same as page title if term_title and mw.loadData("Module:headword/data").pagename == term_title then insert(categories, "Forms linking to themselves") end -- maybe add tracking category if primary entry doesn't exist (this is an -- expensive call so we don't do it by default) if iargs.noprimaryentrycat and term_title and mw.title.getCurrentTitle().nsText == "" and not mw.title.new(term_title):getContent() then insert(categories, lang:getFullName() .. " " .. m_sinhala.sinhala(iargs.noprimaryentrycat)) end end local lemmas if iargs.nolink then lemmas = nil elseif iargs.linktext then lemmas = iargs.linktext else if iargs.with_multiple_parts then lemmas = terms else lemmas = terms.terms end if not lemmas[1] then if mw.title.getCurrentTitle().nsText == "සැකිල්ල" then lemmas[1] = { lang = lang, term = "term" } else error("No linked-to term specified") end end for _, termobj in ipairs(lemmas) do if termobj.term then add_term_tracking_categories(termobj.term) end -- NOTE: Formerly, template arg sc= overrode inline modifier <sc:...>, which seems backwards, so I've -- changed it. Hopefully nothing depended on the old behavior. end end local enclitics, enclitic_conj if args.enclitic then local enclitics_obj = parse_terms_with_inline_modifiers("enclitic", args.enclitic, get_param_mods("with conj"), lang) enclitics = enclitics_obj.terms enclitic_conj = enclitics_obj.conj end local base_lemmas = {} if base_lemma_params then for _, base_lemma_param_obj in ipairs(base_lemma_params) do local param = base_lemma_param_obj.param if args[param] then local base_lemmas_obj = parse_terms_with_inline_modifiers(param, args[param], get_param_mods("with conj"), lang) insert(base_lemmas, { paramobj = base_lemma_param_obj, lemmas = base_lemmas_obj.terms, conj = base_lemmas_obj.conj, }) end end end local posttext = iargs.posttext local addl = args.addl if addl then posttext = posttext or "" if addl:find("^[;:]") then posttext = posttext .. addl elseif addl:find("^_") then posttext = posttext .. " " .. addl:sub(2) else posttext = posttext .. ", " .. addl end end local conj if iargs.with_multiple_parts then conj = false -- signals to use 'separator' field else conj = terms and terms.conj or iargs.conj end local lemma_data = { lang = lang, args = args, lemmas = lemmas, conj = conj, enclitics = enclitics, enclitic_conj = enclitic_conj, base_lemmas = base_lemmas, categories = categories, posttext = posttext, lit = iargs.with_multiple_parts and args.lit.default or nil, } local form_of_text, lang_cats = do_form_of(lemma_data) extend(lemma_data.categories, lang_cats) local text = form_of_text .. ( args.nodot and "" or args.dot or iargs.withdot and "." or "" ) if not lemma_data.categories[1] then return text end return text .. format_categories(lemma_data.categories, lemma_data.lang, args.sort, -- If lemma_is_sort_key is given, supply the first lemma term as the sort base if possible. If sort= is given, -- it will override the base; otherwise, the base will be converted appropriately to a sort key using the -- same algorithm applied to pagenames. iargs.lemma_is_sort_key and type(lemma_data.lemmas) == "table" and lemma_data.lemmas[1].term, -- Supply the first lemma's script for sort key computation. force_cat or get_force_cat(), type(lemma_data.lemmas) == "table" and lemma_data.lemmas[1].sc) end -- Invocation parameters shared between form_of_t(), tagged_form_of_t() and inflection_of_t(). `calling_func` is the -- invoking function ("form_of_t", "tagged_form_of_t" or "inflection_of_t"), for handling parameters shared by two but -- not all three invoking functions. local function get_common_invocation_params(calling_func) local iparams = { ["term_param"] = {type = "number"}, ["lang"] = true, -- To be used as the default code in params. ["sc"] = {type = "script"}, ["cat"] = {list = true, sublist = "comma without whitespace", flatten = true}, ["ignore"] = {list = true}, ["def"] = {list = true}, ["conj"] = {set = allowed_conj_set, default = "and"}, ["withcap"] = boolean_param, ["withencap"] = boolean_param, ["withdot"] = boolean_param, ["nolink"] = boolean_param, ["linktext"] = true, ["posttext"] = true, ["noprimaryentrycat"] = true, ["lemma_is_sort_key"] = true, } if calling_func ~= "inflection_of_t" then iparams.with_multiple_parts = boolean_param end return iparams end local function should_ucfirst_text(args, iargs, lang) local code = lang:getCode() return args.cap or (iargs.withcap or iargs.withencap and code == "en" or code == "mul") and not args.nocap end --[==[ Function that implements {{tl|form of}} and the various more specific form-of templates (but not {{tl|inflection of}} or templates that take tagged inflection parameters). Invocation params: ; {{para|1|req=1}} : Text to display before the link. ; {{para|term_param}} : Numbered param holding the term linked to. Other numbered params come after. Defaults to 1 if invocation or template param {{para|lang}} is present, otherwise 2. ; {{para|with_multiple_parts|1}} : If specified, higher numbered parameters above the numbered param in {{para|term_param}} specify additional parts out of which the term was constructed, for use by templates like {{tl|contraction of}}. (If not specified, the parameter at <code><var>term_param</var> + 1</code> is the display form, same as {{para|alt}}, and the parameter at at <code><var>term_param</var> + 2</code> is the gloss, same as {{para|t}}.) ; {{para|lang}} : Default language code for language-specific templates. If specified, no language code needs to be specified, and if specified it needs to be set using {{para|lang}}, not {{para|1}}. ; {{para|sc}} : Default script code for language-specific templates. The script code can still be overridden using template param {{para|sc}}. ; {{para|cat}}, {{para|cat2}}, ...: : Categories to place the page into. The language name will automatically be prepended. Note that there is also a template param {{para|cat}} to specify categories at the template level. Use of {{para|nocat}} disables categorization of categories specified using invocation param {{para|cat}}, but not using template param {{para|cat}}. A single param can specify multiple comma-separated categories if no space follows the comma. ; {{para|ignore}}, {{para|ignore2}}, ...: : One or more template params to silently accept and ignore. Useful e.g. when the template takes additional parameters such as {{para|from}} or {{para|POS}}. Each value is a comma-separated list of either bare parameter names or specifications of the form `PARAM:list` to specify that the parameter is a list parameter. ; {{para|def}}, {{para|def2}}, ...: : One or more default values to supply for template args. For example, specifying {{para|def|2=tr=-}} causes the default for template param {{para|tr}} to be `-`. Actual template params override these defaults. ; {{para|withcap|1}} : Capitalize the first character of the text preceding the link, unless template param {{para|nocap}} is given. ; {{para|withencap|1}} : Capitalize the first character of the text preceding the link if the language is English and template param {{para|nocap}} is not given. ; {{para|withdot|1}} : Add a final period after the link, unless template param {{para|nodot}} is given to suppress the period, or {{para|dot}} is given to specify an alternative punctuation character. ; {{para|nolink|1}} : Suppress the display of the link. If specified, none of the template params that control the link ({{para|<var>term_param</var>}}, {{para|<var>term_param</var> + 1}}, {{para|<var>term_param</var> + 2}}, {{para|t}}, {{para|gloss}}, {{para|sc}}, {{para|tr}}, {{para|ts}}, {{para|pos}}, {{para|g}}, {{para|id}}, {{para|lit}}) will be available. If the calling template uses any of these parameters, they must be ignored using {{para|ignore}}. {{para|linktext}} : Override the display of the link with the specified text. This is useful if a custom template is available to format the link (e.g. in Hebrew, Chinese and Japanese). If specified, none of the template params that control the link ({{para|<var>term_param</var>}}, {{para|<var>term_param</var> + 1}}, {{para|<var>term_param</var> + 2}}, {{para|t}}, {{para|gloss}}, {{para|sc}}, {{para|tr}}, {{para|ts}}, {{para|pos}}, {{para|g}}, {{para|id}}, {{para|lit}}) will be available. If the calling template uses any of these parameters, they must be ignored using {{para|ignore}}. ; {{para|posttext}} : Additional text to display directly after the formatted link, before any terminating period/dot and inside of `<span class='use-with-mention'>`. ; {{para|noprimaryentrycat}} : Category to add the page to if the primary entry linked to doesn't exist. The language name will automatically be prepended. ; {{para|lemma_is_sort_key|1}} : If the user didn't specify a sort key, use the lemma as the sort key (instead of the page itself). ]==] function export.form_of_t(frame) local iparams = get_common_invocation_params("form_of_t") iparams[1] = {required = true} local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() if next(iargs.cat) then params.nocat = boolean_param end return construct_form_of_text { template = "form-of-t", iargs = iargs, parent_args = parent_args, params = params, do_form_of = function(lemma_data) local args = lemma_data.args local text if args.notext then text = "" else text = iargs[1] if should_ucfirst_text(args, iargs, lemma_data.lang) then text = ucfirst(text) end end -- This returns two values, which we pass up to the caller. return format_form_of { lang = lemma_data.lang, text = text, lemmas = lemma_data.lemmas, conj = lemma_data.conj, enclitics = lemma_data.enclitics, base_lemmas = lemma_data.base_lemmas, lemma_face = "term", lit = lemma_data.lit, posttext = lemma_data.posttext } end } end --[=[ Construct and return the full definition line for a form-of-type template invocation that is based on inflection tags. This is a wrapper around construct_form_of_text() and takes the following arguments: processed invocation arguments IARGS, processed parent arguments ARGS, TERM_PARAM (the parent argument specifying the main entry), COMPAT (true if the language code is found in args.lang instead of args[1]), and TAGS, the list of (non-canonicalized) inflection tags. It returns that actual definition-line text including terminating period/full-stop, formatted categories, etc. and should be directly returned as the template function's return value. ]=] local function construct_tagged_form_of_text(data) local template, iargs, parent_args, params, no_numbered_gloss, tags = data.template, data.iargs, data.parent_args, data.params, data.no_numbered_gloss, data.tags -- Named params not controlling link display -- Always included because lang-specific categories may be added params.nocat = boolean_param params.p = true params.POS = {alias_of = "p"} return construct_form_of_text { template = template, iargs = iargs, parent_args = parent_args, params = params, no_numbered_gloss = no_numbered_gloss, do_form_of = function(lemma_data) local args = lemma_data.args if is_callable(tags) then tags = tags(args) end -- NOTE: tagged_inflections returns two values, so we do too. return tagged_inflections { lang = lemma_data.lang, tags = tags, lemmas = lemma_data.lemmas, conj = lemma_data.conj, enclitics = lemma_data.enclitics, enclitic_conj = lemma_data.enclitic_conj, base_lemmas = lemma_data.base_lemmas, lemma_face = "term", POS = args.p, pagename = args.pagename, -- Set no_format_categories because we do it ourselves in construct_form_of_text(). no_format_categories = true, nocat = args.nocat, notext = args.notext, capfirst = should_ucfirst_text(args, iargs, lemma_data.lang), posttext = lemma_data.posttext, } end } end --[==[ Function that implements form-of templates that are defined by specific tagged inflections (typically a template referring to a non-lemma inflection, such as {{tl|plural of}}). This works exactly like {form_of_t()} except that the "form of" text displayed before the link is based off of a pre-specified set of inflection tags (which will be appropriately linked to the glossary) instead of arbitrary text. From the user's perspective, there is no difference between templates implemented using {form_of_t()} and {tagged_form_of_t()}; they accept exactly the same parameters and work the same. See also {inflection_of_t()} below, which is intended for templates with user-specified inflection tags. Invocation params: ; {{para|1|req=1}}, {{para|2}}, ... : One or more inflection tags describing the inflection in question. ; {{para|split_tags}} : If specified, character to split specified inflection tags on. This allows multiple tags to be included in a single argument, simplifying template code. ; {{para|term_param}} ; {{para|with_multiple_parts|1}} ; {{para|lang}} ; {{para|sc}} ; {{para|cat}}, {{para|cat2}}, ... ; {{para|ignore}}, {{para|ignore2}}, ... ; {{para|def}}, {{para|def2}}, ... ; {{para|withcap|1}} ; {{para|withencap|1}} ; {{para|withdot|1}} ; {{para|nolink|1}} ; {{para|linktext}} ; {{para|posttext}} ; {{para|noprimaryentrycat}} ; {{para|lemma_is_sort_key|1}} : All of these are the same as in {form_of_t()}. ]==] function export.tagged_form_of_t(frame) local iparams = get_common_invocation_params("tagged_form_of_t") iparams[1] = {list = true, required = true} iparams.split_tags = true local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() return construct_tagged_form_of_text { template = "tagged-form-of-t", iargs = iargs, parent_args = parent_args, params = params, tags = split_inflection_tags(iargs[1], iargs.split_tags), } end --[==[ Function that implements {{tl|inflection of}} and certain semi-specific variants, such as {{tl|participle of}} and {{tl|past participle form of}}. This function is intended for templates that allow the user to specify a set of inflection tags. It works similarly to {form_of_t()} and {tagged_form_of_t()} except that the calling convention for the calling template is : { {{TEMPLATE|LANG|MAIN_ENTRY_LINK|MAIN_ENTRY_DISPLAY_TEXT|TAG|TAG|...}}} instead of : { {{TEMPLATE|LANG|MAIN_ENTRY_LINK|MAIN_ENTRY_DISPLAY_TEXT|GLOSS}}} Note that there isn't a numbered parameter for the gloss, but it can still be specified using {{para|t}} or {{para|gloss}}. Invocation params: ; {{para|preinfl}}, {{para|preinfl2}}, ... : Extra inflection tags to automatically prepend to the tags specified by the template. ; {{para|postinfl}}, {{para|postinfl2}}, ... : Extra inflection tags to automatically append to the tags specified by the template. Used for example by {{tl|past participle form of}} to add the tags `of the|past|p` onto the user-specified tags, which indicate which past participle form the page refers to. ; {{para|split_tags}} : If specified, character to split specified inflection tags on. This allows multiple tags to be included in a single argument, simplifying template code. Note that this applies *ONLY* to inflection tags specified in the invocation arguments using {{para|preinfl}} or {{para|postinfl}}, not to user-specified inflection tags. ; {{para|term_param}} ; {{para|lang}} ; {{para|sc}} ; {{para|cat}}, {{para|cat2}}, ... ; {{para|ignore}}, {{para|ignore2}}, ... ; {{para|def}}, {{para|def2}}, ... ; {{para|withcap|1}} ; {{para|withencap|1}} ; {{para|withdot|1}} ; {{para|nolink|1}} ; {{para|linktext}} ; {{para|posttext}} ; {{para|noprimaryentrycat}} ; {{para|lemma_is_sort_key|1}} : All of these are the same as in {form_of_t()}. ]==] function export.inflection_of_t(frame) local iparams = get_common_invocation_params("inflection_of_t") iparams.preinfl = {list = true} iparams.postinfl = {list = true} iparams.split_tags = true local iargs = process_params(frame.args, iparams) local parent_args = frame:getParent().args local params = get_common_template_params() local compat = iargs.lang or parent_args.lang local tagsind = (iargs.term_param or compat and 1 or 2) + 2 params[tagsind] = {list = true, -- at least one inflection tag is required unless preinfl or postinfl tags are given required = #iargs.preinfl == 0 and #iargs.postinfl == 0} return construct_tagged_form_of_text { template = "inflection-of-t", iargs = iargs, parent_args = parent_args, params = params, no_numbered_gloss = true, tags = function(args) local infls if not next(iargs.preinfl) and not next(iargs.postinfl) then -- If no preinfl or postinfl tags, just use the user-specified tags directly. infls = args[tagsind] else -- Otherwise, we need to prepend the preinfl tags and postpend the postinfl tags. If there's only one tag set -- (no semicolon), it's easier. Since this is common, we optimize for it. infls = {} local saw_semicolon = false for _, infl in ipairs(args[tagsind]) do if infl == ";" then saw_semicolon = true break end end local split_preinfl = split_inflection_tags(iargs.preinfl, iargs.split_tags) local split_postinfl = split_inflection_tags(iargs.postinfl, iargs.split_tags) if not saw_semicolon then extend(infls, split_preinfl) extend(infls, args[tagsind]) extend(infls, split_postinfl) else local groups = split_tag_set(args[tagsind]) for _, group in ipairs(groups) do if #infls > 0 then insert(infls, ";") end extend(infls, split_preinfl) extend(infls, group) extend(infls, split_postinfl) end end end return infls end, } end --[==[ Normalize a part-of-speech tag given a possible abbreviation (passed in as {{para|1}} of the invocation args). If the abbreviation isn't recognized, the original POS tag is returned. If no POS tag is passed in, return the value of invocation arg {{para|default}}. ]==] function export.normalize_pos(frame) local iparams = { [1] = true, ["default"] = true, } local iargs = process_params(frame.args, iparams) if not iargs[1] and not iargs.default then error("Either 1= or default= must be given in the invocation args") end if not iargs[1] then return iargs.default end return (m_form_of_pos or get_m_form_of_pos())[iargs[1]] or iargs[1] end return export cpqdygqmjl5iokudlwso7xy5hgqqhh9 සැකිල්ල:character info/A 10 9055 238989 31736 2026-11-14T07:42:41Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238989 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:LetterA.svg|120x140px]][[Category:Character boxes with images|*0000000065]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#65;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=0041 U+0041], [[w:List of XML and HTML character entity references|&amp;#65;]] <div class="character-sample-name">LATIN CAPITAL LETTER A</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[@|<span title="COMMERCIAL AT">← <span class="character-sample-secondary None">&#x0040;</span><br><small>[U+0040]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000065]] <td style="width:20%">[[B|<span title="LATIN CAPITAL LETTER B"><span class="character-sample-secondary Latn">&#x0042;</span> →<br><small>[U+0042]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| A]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/A]]. Its edit history can be viewed at [[සැකිල්ල:character info/A/edithistory]]</small></noinclude> cehocleehsj79s9ror3phn7fpj86k9g සැකිල්ල:character info/I 10 9057 238990 210988 2026-11-14T07:42:51Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238990 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:LetterI.svg|120x140px]][[Category:Character boxes with images|*0000000073]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#73;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=0049 U+0049], [[w:List of XML and HTML character entity references|&amp;#73;]] <div class="character-sample-name">LATIN CAPITAL LETTER I</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[H|<span title="LATIN CAPITAL LETTER H">← <span class="character-sample-secondary Latn">&#x0048;</span><br><small>[U+0048]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000073]] <td style="width:20%">[[J|<span title="LATIN CAPITAL LETTER J"><span class="character-sample-secondary Latn">&#x004A;</span> →<br><small>[U+004A]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| I]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/I]]. Its edit history can be viewed at [[සැකිල්ල:character info/I/edithistory]]</small></noinclude> tax54tfkgmlx19w5rqxkd9pycx5yh86 සැකිල්ල:character info/O 10 9059 238991 210990 2026-11-14T07:43:01Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238991 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:LetterO.svg|120x140px]][[Category:Character boxes with images|*0000000079]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#79;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=004F U+004F], [[w:List of XML and HTML character entity references|&amp;#79;]] <div class="character-sample-name">LATIN CAPITAL LETTER O</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[N|<span title="LATIN CAPITAL LETTER N">← <span class="character-sample-secondary Latn">&#x004E;</span><br><small>[U+004E]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000079]] <td style="width:20%">[[P|<span title="LATIN CAPITAL LETTER P"><span class="character-sample-secondary Latn">&#x0050;</span> →<br><small>[U+0050]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| O]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/O]]. Its edit history can be viewed at [[සැකිල්ල:character info/O/edithistory]]</small></noinclude> memky5ps78airln7y5bi1qhkpt3kcd8 සැකිල්ල:character info/a 10 9061 238992 210987 2026-11-14T07:43:11Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238992 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:Letter a.svg|120x140px]][[Category:Character boxes with images|*0000000097]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#97;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=0061 U+0061], [[w:List of XML and HTML character entity references|&amp;#97;]] <div class="character-sample-name">LATIN SMALL LETTER A</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[`|<span title="GRAVE ACCENT">← <span class="character-sample-secondary Zyyy">&#x0060;</span><br><small>[U+0060]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000097]] <td style="width:20%">[[b|<span title="LATIN SMALL LETTER B"><span class="character-sample-secondary Latn">&#x0062;</span> →<br><small>[U+0062]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| a]]<noinclude> <small>This page was moved from [[en:Template:character info/a]]. Its edit history can be viewed at [[සැකිල්ල:character info/a/edithistory]]</small></noinclude> 1bpk5qigc8dvpe6914w2ytjzyitznw6 සැකිල්ල:character info/i 10 9065 238993 210989 2026-11-14T07:43:21Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238993 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:Letter i.svg|120x140px]][[Category:Character boxes with images|*0000000105]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#105;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=0069 U+0069], [[w:List of XML and HTML character entity references|&amp;#105;]] <div class="character-sample-name">LATIN SMALL LETTER I</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[h|<span title="LATIN SMALL LETTER H">← <span class="character-sample-secondary Latn">&#x0068;</span><br><small>[U+0068]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000105]] <td style="width:20%">[[j|<span title="LATIN SMALL LETTER J"><span class="character-sample-secondary Latn">&#x006A;</span> →<br><small>[U+006A]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| i]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/i]]. Its edit history can be viewed at [[සැකිල්ල:character info/i/edithistory]]</small></noinclude> 9vf35blj0l7342pq8n2vd1tzfg8wfq7 සැකිල්ල:character info/o 10 9069 238994 210991 2026-11-14T07:43:31Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238994 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:Letter o.svg|120x140px]][[Category:Character boxes with images|*0000000111]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#111;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=006F U+006F], [[w:List of XML and HTML character entity references|&amp;#111;]] <div class="character-sample-name">LATIN SMALL LETTER O</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[n|<span title="LATIN SMALL LETTER N">← <span class="character-sample-secondary Latn">&#x006E;</span><br><small>[U+006E]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000111]] <td style="width:20%">[[p|<span title="LATIN SMALL LETTER P"><span class="character-sample-secondary Latn">&#x0070;</span> →<br><small>[U+0070]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| o]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/o]]. Its edit history can be viewed at [[සැකිල්ල:character info/o/edithistory]]</small></noinclude> t96d974exy47vf7dveolqac1o8nug9f සැකිල්ල:character info/u 10 9073 238995 210992 2026-11-14T07:43:41Z Pinthura 2424 Bot: Replacing category Basic Latin block with [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය|Basic Latin කාණ්ඩය]] 238995 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:Letter u.svg|120x140px]][[Category:Character boxes with images|*0000000117]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Latn">&#117;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=0075 U+0075], [[w:List of XML and HTML character entity references|&amp;#117;]] <div class="character-sample-name">LATIN SMALL LETTER U</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[t|<span title="LATIN SMALL LETTER T">← <span class="character-sample-secondary Latn">&#x0074;</span><br><small>[U+0074]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Basic Latin|Basic Latin]][[ප්‍රවර්ගය:Basic Latin කාණ්ඩය|*0000000117]] <td style="width:20%">[[v|<span title="LATIN SMALL LETTER V"><span class="character-sample-secondary Latn">&#x0076;</span> →<br><small>[U+0076]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:ලතින් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| u]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/u]]. Its edit history can be viewed at [[සැකිල්ල:character info/u/edithistory]]</small></noinclude> 3l2r3vr6z8i5b0yocwrco9o87y7vs6z සැකිල්ල:character info/и 10 9075 238987 214223 2026-11-14T03:34:34Z Pinthura 2424 Bot: Replacing category Cyrillic block with [[:ප්‍රවර්ගය:සිරිලික් කාණ්ඩය|සිරිලික් කාණ්ඩය]] 238987 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | colspan="2" style="text-align: center;" | [[File:Cirila-и-minuskla.svg|120x140px]][[Category:Character boxes with images|*0000001080]]<br/> |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Cyrl">&#1080;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=0438 U+0438], [[w:List of XML and HTML character entity references|&amp;#1080;]] <div class="character-sample-name">CYRILLIC SMALL LETTER I</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[з|<span title="CYRILLIC SMALL LETTER ZE">← <span class="character-sample-secondary Cyrl">&#x0437;</span><br><small>[U+0437]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/Cyrillic|Cyrillic]][[ප්‍රවර්ගය:සිරිලික් කාණ්ඩය|*0000001080]] <td style="width:20%">[[й|<span title="CYRILLIC SMALL LETTER SHORT I"><span class="character-sample-secondary Cyrl">&#x0439;</span> →<br><small>[U+0439]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:සිරිලික් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| и]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/и]]. Its edit history can be viewed at [[සැකිල්ල:character info/и/edithistory]]</small></noinclude> 8obp8s6s2w2qspvu5hupy1w2gy4hq21 සැකිල්ල:character info/⻘ 10 9083 238988 35015 2026-11-14T03:34:55Z Pinthura 2424 Bot: Replacing category CJK Radicals Supplement block with [[:ප්‍රවර්ගය:CJK Radicals Supplement කාණ්ඩය|CJK Radicals Supplement කාණ්ඩය]] 238988 wikitext text/x-wiki {| class="wikitable floatright" style="width:25em;" |- | style="width: 70px;" colspan="2" | <table><tr><td><span class="character-sample-primary Hani">&#11992;</span></td><td> [https://util.unicode.org/UnicodeJsps/character.jsp?a=2ED8 U+2ED8], [[w:List of XML and HTML character entity references|&amp;#11992;]] <div class="character-sample-name">CJK RADICAL BLUE</div></td></tr></table><table style="width:100%;font-size:80%;white-space:nowrap"><tr><td style="width:50%;text-align:left"></td><td style="width:50%;text-align:right"></td></tr></table> <table style="width:100%;text-align:center"><tr><td style="width:20%">[[⻗|<span title="CJK RADICAL RAIN">← <span class="character-sample-secondary Hani">&#x2ED7;</span><br><small>[U+2ED7]</small></span>]] </td><td style="width:60%;font-size:110%;font-weight:bold">[[Appendix:Unicode/CJK Radicals Supplement|CJK Radicals Supplement]][[ප්‍රවර්ගය:CJK Radicals Supplement කාණ්ඩය|*0000011992]] <td style="width:20%">[[⻙|<span title="CJK RADICAL C-SIMPLIFIED TANNED LEATHER"><span class="character-sample-secondary Hani">&#x2ED9;</span> →<br><small>[U+2ED9]</small></span>]] </td></td></tr></table> |}[[ප්‍රවර්ගය:හන් අක්ෂරක්‍රමය තුළ භාවිතා වන අනුලක්ෂණ| ⻘]]<templatestyles src="Template:character info/style.css"></templatestyles><noinclude> <small>This page was moved from [[en:Template:character info/⻘]]. Its edit history can be viewed at [[සැකිල්ල:character info/⻘/edithistory]]</small></noinclude> jfalh8kov9eeprhfdyuw00joajwwnwy ප්‍රවර්ගය:CJK Unified Ideographs කාණ්ඩය 14 9238 238941 31503 2026-11-14T02:52:23Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Unified Ideographs block]] සිට [[ප්‍රවර්ගය:CJK Unified Ideographs කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 31502 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238953 238941 2026-11-14T02:53:33Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238953 wikitext text/x-wiki {{autocat}} [[en:Category:CJK Unified Ideographs block]] 6y3xhext3vy00fejy2riqgv8mxmmiuw 238974 238953 2026-11-14T02:56:33Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238974 wikitext text/x-wiki {{auto cat}} [[en:Category:CJK Unified Ideographs block]] 2zr5sbqjink0t6hr5fqefifc17p0hmc ප්‍රවර්ගය:Basic Latin කාණ්ඩය 14 9902 238921 33286 2026-11-14T02:46:22Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Basic Latin block]] සිට [[ප්‍රවර්ගය:Basic Latin කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 33285 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238924 238921 2026-11-14T02:46:42Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238924 wikitext text/x-wiki {{autocat}} [[en:Category:Basic Latin block]] pjjxh7gwaqtnpaov6kbiefw8j0qjsb1 238928 238924 2026-11-14T02:47:22Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238928 wikitext text/x-wiki {{auto cat}} [[en:Category:Basic Latin block]] oar7czo30m9ruai99j7y9ejbj7n451j ප්‍රවර්ගය:දේවනාගරි කාණ්ඩය 14 12051 238947 38680 2026-11-14T02:52:43Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Devanagari block]] සිට [[ප්‍රවර්ගය:දේවනාගරි කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 38679 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238955 238947 2026-11-14T02:53:53Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238955 wikitext text/x-wiki {{autocat}} [[en:Category:Devanagari block]] i5b3qjc4ld7xs3ff8lg1j6kvvuowd5p 238976 238955 2026-11-14T02:56:53Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238976 wikitext text/x-wiki {{auto cat}} [[en:Category:Devanagari block]] o6obbknuq3fge394zfznn66zcz2e2fd ප්‍රවර්ගය:CJK Compatibility Ideographs කාණ්ඩය 14 12625 238931 40057 2026-11-14T02:51:53Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Compatibility Ideographs block]] සිට [[ප්‍රවර්ගය:CJK Compatibility Ideographs කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 40056 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238950 238931 2026-11-14T02:53:03Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238950 wikitext text/x-wiki {{autocat}} [[en:Category:CJK Compatibility Ideographs block]] i0qn2zu8iknsmv3xxor3ik9s8n83x6b 238970 238950 2026-11-14T02:56:03Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238970 wikitext text/x-wiki {{auto cat}} [[en:Category:CJK Compatibility Ideographs block]] gz9am3octzs5j9j7hhcmasqnez8hag6 ප්‍රවර්ගය:CJK Compatibility කාණ්ඩය 14 13270 238929 41210 2026-11-14T02:51:43Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Compatibility block]] සිට [[ප්‍රවර්ගය:CJK Compatibility කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 41209 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238949 238929 2026-11-14T02:52:53Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238949 wikitext text/x-wiki {{autocat}} [[en:Category:CJK Compatibility block]] r75p5sw9gbq5jskr03a9xs9nnygj61r 238967 238949 2026-11-14T02:55:53Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238967 wikitext text/x-wiki {{auto cat}} [[en:Category:CJK Compatibility block]] 1b6kmt7w4t532uk1itnlwl3uvxgghxc ප්‍රවර්ග සාකච්ඡාව:Braille Patterns කාණ්ඩය 15 22797 238919 59315 2026-11-14T02:46:12Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:Braille Patterns block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:Braille Patterns කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59315 wikitext text/x-wiki {| class="wikitable" ! oldid || date/time || username || edit summary |---- | 40526713 || 2016-09-13T13:03:59Z || Daniel Carrero || <nowiki>Created page with "{{autocat}}"</nowiki> |} 4kib90lou28hnyjhkgxd1c3i3cpops4 ප්‍රවර්ගය:Braille Patterns කාණ්ඩය 14 22799 238917 59317 2026-11-14T02:46:12Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Braille Patterns block]] සිට [[ප්‍රවර්ගය:Braille Patterns කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59317 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238923 238917 2026-11-14T02:46:32Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238923 wikitext text/x-wiki {{autocat}} [[en:Category:Braille Patterns block]] nqgx2j3tfi8fat0n6wvj44cr6cwm6hd 238927 238923 2026-11-14T02:47:12Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238927 wikitext text/x-wiki {{auto cat}} [[en:Category:Braille Patterns block]] dwyvvvv1k9pag3jwor0bbo08b1q3294 ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement කාණ්ඩය 15 22801 238935 59319 2026-11-14T02:52:03Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59319 wikitext text/x-wiki {| class="wikitable" ! oldid || date/time || username || edit summary |---- | 40535851 || 2016-09-14T11:26:33Z || Daniel Carrero || <nowiki>Created page with "{{autocat}}"</nowiki> |} do52py3vjxguphqacnblsutllw7vzep ප්‍රවර්ගය:CJK Radicals Supplement කාණ්ඩය 14 22803 238933 59321 2026-11-14T02:52:03Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Radicals Supplement block]] සිට [[ප්‍රවර්ගය:CJK Radicals Supplement කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59321 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238951 238933 2026-11-14T02:53:13Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238951 wikitext text/x-wiki {{autocat}} [[en:Category:CJK Radicals Supplement block]] sflh0x9w7qrgy2uyw2utwnusrdza473 238971 238951 2026-11-14T02:56:13Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238971 wikitext text/x-wiki {{auto cat}} [[en:Category:CJK Radicals Supplement block]] 5qnzcnqyesqnsn5pqswjc2nm1i7ukln ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation කාණ්ඩය 15 22805 238939 59323 2026-11-14T02:52:13Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59323 wikitext text/x-wiki {| class="wikitable" ! oldid || date/time || username || edit summary |---- | 40535821 || 2016-09-14T11:21:32Z || Daniel Carrero || <nowiki>Created page with "{{autocat}}"</nowiki> |} pp9499jjggl6z1u739zxfd3tpahdq4c ප්‍රවර්ගය:CJK Symbols and Punctuation කාණ්ඩය 14 22807 238937 59325 2026-11-14T02:52:13Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Symbols and Punctuation block]] සිට [[ප්‍රවර්ගය:CJK Symbols and Punctuation කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59325 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238952 238937 2026-11-14T02:53:23Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238952 wikitext text/x-wiki {{autocat}} [[en:Category:CJK Symbols and Punctuation block]] 6ggpfgahf7olhh339sqle49wggxzk9w 238973 238952 2026-11-14T02:56:23Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238973 wikitext text/x-wiki {{auto cat}} [[en:Category:CJK Symbols and Punctuation block]] 1jt7tsa1mvs2ks26nbnfjoq65z65hwj ප්‍රවර්ග සාකච්ඡාව:සිරිලික් කාණ්ඩය 15 22843 238945 59367 2026-11-14T02:52:33Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:Cyrillic block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:සිරිලික් කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59367 wikitext text/x-wiki {| class="wikitable" ! oldid || date/time || username || edit summary |---- | 40525673 || 2016-09-13T09:11:35Z || Daniel Carrero || <nowiki>Created page with "{{autocat}}"</nowiki> |} e0s94rzhu6sb4xmulaexsw274dk27vc ප්‍රවර්ගය:සිරිලික් කාණ්ඩය 14 22844 238943 59369 2026-11-14T02:52:33Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Cyrillic block]] සිට [[ප්‍රවර්ගය:සිරිලික් කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 59369 wikitext text/x-wiki {{autocat}} slf0sbtwkqpj1yctqc9wbjjf1tuf7jr 238954 238943 2026-11-14T02:53:43Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238954 wikitext text/x-wiki {{autocat}} [[en:Category:Cyrillic block]] ft1tkrdgrvn19gfyxb3s1855mmnjbxx 238975 238954 2026-11-14T02:56:43Z Pinthura 2424 සේවා: auto cat භාවිතය පරික්ෂාව 238975 wikitext text/x-wiki {{auto cat}} [[en:Category:Cyrillic block]] 0rul7rh0p1x63kow7zub9txzjyrmhpz ප්‍රවර්ගය:Sanskrit navigation templates 14 145780 238910 238908 2026-11-14T02:33:05Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238910 wikitext text/x-wiki {{category redirect|සංස්කෘත මං සලකුණු සැකිලි}} fa2b1wazf9q0of4ps7bzb5wtz3x86wn ප්‍රවර්ගය:Navigation templates by language 14 145786 238911 238907 2026-11-14T02:33:15Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238911 wikitext text/x-wiki {{category redirect|භාෂාව අනුව මං සලකුණු සැකිලි}} m0aszykscykq8o8jh71fqwousccnocj ප්‍රවර්ගය:භාෂාව අනුව Navigation templates 14 145787 238912 238876 2026-11-14T02:33:25Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238912 wikitext text/x-wiki {{category redirect|භාෂාව අනුව මං සලකුණු සැකිලි}} m0aszykscykq8o8jh71fqwousccnocj ප්‍රවර්ගය:සංස්කෘත navigation templates 14 145788 238913 238879 2026-11-14T02:33:35Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238913 wikitext text/x-wiki {{category redirect|සංස්කෘත මං සලකුණු සැකිලි}} fa2b1wazf9q0of4ps7bzb5wtz3x86wn ප්‍රවර්ගය:Terms in nonstandard scripts by language 14 145789 238914 238882 2026-11-14T02:33:45Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238914 wikitext text/x-wiki {{category redirect|භාෂාව අනුව Terms in nonstandard scripts}} 3wpy5ufuf71563vvtx1fqln40p6ac07 ප්‍රවර්ගය:Ashéninka Pajonal භාෂාව 14 145794 238915 238893 2026-11-14T02:33:55Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238915 wikitext text/x-wiki {{category redirect|Pajonal Ashéninka භාෂාව}} 2y44nepsi6fxljlsvaagpn2d0y88v0o ප්‍රවර්ගය:Ashéninka Pajonal සැකිලි 14 145795 238916 238895 2026-11-14T02:34:05Z Pinthura 2424 රොබෝ: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම 238916 wikitext text/x-wiki {{category redirect|Pajonal Ashéninka සැකිලි}} 29vlivcrt0sa8hsm144wa3gqftxp5w8 ප්‍රවර්ගය:Braille Patterns block 14 145797 238918 2026-11-14T02:46:12Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Braille Patterns block]] සිට [[ප්‍රවර්ගය:Braille Patterns කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238918 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:Braille Patterns කාණ්ඩය]] paa6f0ubxd908hji8yiulrsdirmmr1g 238925 238918 2026-11-14T02:46:52Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238925 wikitext text/x-wiki {{category redirect|Braille Patterns කාණ්ඩය}} g2t0t3tx26qmo9q8nsszik06uadpcfn ප්‍රවර්ග සාකච්ඡාව:Braille Patterns block 15 145798 238920 2026-11-14T02:46:12Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:Braille Patterns block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:Braille Patterns කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238920 wikitext text/x-wiki #යළියොමුව [[ප්‍රවර්ග සාකච්ඡාව:Braille Patterns කාණ්ඩය]] lnlk089xipfwk2f9tl7n0ro4u3xl535 ප්‍රවර්ගය:Basic Latin block 14 145799 238922 2026-11-14T02:46:22Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Basic Latin block]] සිට [[ප්‍රවර්ගය:Basic Latin කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238922 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:Basic Latin කාණ්ඩය]] cbp7l863zja3px1li1urxq4uh6byefg 238926 238922 2026-11-14T02:47:02Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238926 wikitext text/x-wiki {{category redirect|Basic Latin කාණ්ඩය}} 9kqcfdekx6mwjiay3f80oqbvzsdgf2n ප්‍රවර්ගය:CJK Compatibility block 14 145800 238930 2026-11-14T02:51:43Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Compatibility block]] සිට [[ප්‍රවර්ගය:CJK Compatibility කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238930 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:CJK Compatibility කාණ්ඩය]] 79dw08ywzlr9amu2l67skwh9w5uxky3 238956 238930 2026-11-14T02:54:03Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238956 wikitext text/x-wiki {{category redirect|CJK Compatibility කාණ්ඩය}} cj6zldfmugg3a1elmmgbf2i4ik6d8pw ප්‍රවර්ගය:CJK Compatibility Ideographs block 14 145801 238932 2026-11-14T02:51:53Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Compatibility Ideographs block]] සිට [[ප්‍රවර්ගය:CJK Compatibility Ideographs කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238932 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:CJK Compatibility Ideographs කාණ්ඩය]] a1xl9jf269jgar0icj01rfewyl6q2zy 238957 238932 2026-11-14T02:54:13Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238957 wikitext text/x-wiki {{category redirect|CJK Compatibility Ideographs කාණ්ඩය}} 9aamm7aa5wa4p1sui8knu9942nmughg ප්‍රවර්ගය:CJK Radicals Supplement block 14 145802 238934 2026-11-14T02:52:03Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Radicals Supplement block]] සිට [[ප්‍රවර්ගය:CJK Radicals Supplement කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238934 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:CJK Radicals Supplement කාණ්ඩය]] 3kebfpym1pbsc0nl42lp0qe4021at46 238958 238934 2026-11-14T02:54:23Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238958 wikitext text/x-wiki {{category redirect|CJK Radicals Supplement කාණ්ඩය}} jlhwyj19mh0otkepdq6hlg4dqdka908 ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement block 15 145803 238936 2026-11-14T02:52:03Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238936 wikitext text/x-wiki #යළියොමුව [[ප්‍රවර්ග සාකච්ඡාව:CJK Radicals Supplement කාණ්ඩය]] h5xcjzvex1n4c351xhx2gzl357ebsdw ප්‍රවර්ගය:CJK Symbols and Punctuation block 14 145804 238938 2026-11-14T02:52:13Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Symbols and Punctuation block]] සිට [[ප්‍රවර්ගය:CJK Symbols and Punctuation කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238938 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:CJK Symbols and Punctuation කාණ්ඩය]] k1pi9cb3eiw01cwm14v91085dk8fb7w 238959 238938 2026-11-14T02:54:33Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238959 wikitext text/x-wiki {{category redirect|CJK Symbols and Punctuation කාණ්ඩය}} 00kyuhsoxn0srg58a00z8cn7x6y78z9 ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation block 15 145805 238940 2026-11-14T02:52:13Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238940 wikitext text/x-wiki #යළියොමුව [[ප්‍රවර්ග සාකච්ඡාව:CJK Symbols and Punctuation කාණ්ඩය]] mkscujj6zs879lu8r2qj9q3nss5z2r3 ප්‍රවර්ගය:CJK Unified Ideographs block 14 145806 238942 2026-11-14T02:52:23Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:CJK Unified Ideographs block]] සිට [[ප්‍රවර්ගය:CJK Unified Ideographs කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238942 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:CJK Unified Ideographs කාණ්ඩය]] 76ms11f1nfews3ny6xia2m99bjsmaln 238960 238942 2026-11-14T02:54:43Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238960 wikitext text/x-wiki {{category redirect|CJK Unified Ideographs කාණ්ඩය}} o3f55yexbtnj8lqjlakolef1qs6iavw ප්‍රවර්ගය:Cyrillic block 14 145807 238944 2026-11-14T02:52:33Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Cyrillic block]] සිට [[ප්‍රවර්ගය:සිරිලික් කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238944 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:සිරිලික් කාණ්ඩය]] bcim1ldtqujzw2kmj8b1y0qy4ogjqky 238961 238944 2026-11-14T02:54:53Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238961 wikitext text/x-wiki {{category redirect|සිරිලික් කාණ්ඩය}} 94d3hzav8go2pv1mc382x9s5ipc5uwp ප්‍රවර්ග සාකච්ඡාව:Cyrillic block 15 145808 238946 2026-11-14T02:52:33Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ග සාකච්ඡාව:Cyrillic block]] සිට [[ප්‍රවර්ග සාකච්ඡාව:සිරිලික් කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238946 wikitext text/x-wiki #යළියොමුව [[ප්‍රවර්ග සාකච්ඡාව:සිරිලික් කාණ්ඩය]] bpafs8nr9wgejk1y1c85hg9kq9wcddb ප්‍රවර්ගය:Devanagari block 14 145809 238948 2026-11-14T02:52:43Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Devanagari block]] සිට [[ප්‍රවර්ගය:දේවනාගරි කාණ්ඩය]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238948 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:දේවනාගරි කාණ්ඩය]] 2yes74hncbeu78ubt2bmf4eo120v0xs 238962 238948 2026-11-14T02:55:03Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238962 wikitext text/x-wiki {{category redirect|දේවනාගරි කාණ්ඩය}} 93dfacyte9yfx8k915lfc68okhv10as ප්‍රවර්ගය:Cyrillic කාණ්ඩය 14 145810 238963 2026-11-14T02:55:13Z Pinthura 2424 සේවා: මෘදු ප්‍රවර්ග යළියොමුවක් නිර්මාණය. 238963 wikitext text/x-wiki {{category redirect|සිරිලික් කාණ්ඩය}} 94d3hzav8go2pv1mc382x9s5ipc5uwp ප්‍රවර්ගය:Devanagari කාණ්ඩය 14 145811 238964 2026-11-14T02:55:23Z Pinthura 2424 සේවා: මෘදු ප්‍රවර්ග යළියොමුවක් නිර්මාණය. 238964 wikitext text/x-wiki {{category redirect|දේවනාගරි කාණ්ඩය}} 93dfacyte9yfx8k915lfc68okhv10as ප්‍රවර්ගය:සිරිලික් block 14 145812 238965 2026-11-14T02:55:33Z Pinthura 2424 සේවා: මෘදු ප්‍රවර්ග යළියොමුවක් නිර්මාණය. 238965 wikitext text/x-wiki {{category redirect|සිරිලික් කාණ්ඩය}} 94d3hzav8go2pv1mc382x9s5ipc5uwp ප්‍රවර්ගය:දේවනාගරි block 14 145813 238966 2026-11-14T02:55:43Z Pinthura 2424 සේවා: මෘදු ප්‍රවර්ග යළියොමුවක් නිර්මාණය. 238966 wikitext text/x-wiki {{category redirect|දේවනාගරි කාණ්ඩය}} 93dfacyte9yfx8k915lfc68okhv10as ප්‍රවර්ගය:ඉතාලි නාම පද ස්වරූප 14 145814 238980 2026-11-14T03:05:32Z Pinthura 2424 සේවා: [[:[[en:Category:Italian noun forms]]]] තුළ තිබූ පෙළ මෙහි ඇතුළු කිරීම. 238980 wikitext text/x-wiki {{auto cat}} eomzlm5v4j7ond1phrju7cnue91g5qx 238981 238980 2026-11-14T03:05:42Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Italian noun forms]] සිට [[ප්‍රවර්ගය:ඉතාලි නාම පද ස්වරූප]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238980 wikitext text/x-wiki {{auto cat}} eomzlm5v4j7ond1phrju7cnue91g5qx 238983 238981 2026-11-14T03:05:52Z Pinthura 2424 සේවා: ඉංග්‍රීසි ව්‍යාපෘතිය වෙත සබැඳියක් එක් කිරීම. 238983 wikitext text/x-wiki {{auto cat}} [[en:Category:Italian noun forms]] mkq1abiw14y7m9myh6od23ouhvj2sv2 ප්‍රවර්ගය:Italian noun forms 14 145815 238982 2026-11-14T03:05:43Z Pinthura 2424 Pinthura විසින් [[ප්‍රවර්ගය:Italian noun forms]] සිට [[ප්‍රවර්ගය:ඉතාලි නාම පද ස්වරූප]] වෙත පිටුව ගෙන යන ලදී: සේවා: නව ප්‍රවර්ග නාමය වෙත ගෙනයාම. 238982 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:ඉතාලි නාම පද ස්වරූප]] cuk3hoxvi0vugssuj513wtju7ztx6hr 238984 238982 2026-11-14T03:06:02Z Pinthura 2424 සේවා: යළියොමුව, මෘදු ප්‍රවර්ග යළියොමුවක් බවට හැරවීම. 238984 wikitext text/x-wiki {{category redirect|ඉතාලි නාම පද ස්වරූප}} pm71mozqlalfb8ff7lxtz6jmbn0cwqm ප්‍රවර්ගය:Italian නාම පද ස්වරූප 14 145816 238985 2026-11-14T03:06:12Z Pinthura 2424 සේවා: මෘදු ප්‍රවර්ග යළියොමුවක් නිර්මාණය. 238985 wikitext text/x-wiki {{category redirect|ඉතාලි නාම පද ස්වරූප}} pm71mozqlalfb8ff7lxtz6jmbn0cwqm ප්‍රවර්ගය:ඉතාලි noun forms 14 145817 238986 2026-11-14T03:06:22Z Pinthura 2424 සේවා: මෘදු ප්‍රවර්ග යළියොමුවක් නිර්මාණය. 238986 wikitext text/x-wiki {{category redirect|ඉතාලි නාම පද ස්වරූප}} pm71mozqlalfb8ff7lxtz6jmbn0cwqm