|
|
| Line 2: |
Line 2: |
|
| |
|
| -- Named constants for all modules used, to make it easier to swap out sandbox versions. | | -- Named constants for all modules used, to make it easier to swap out sandbox versions. |
| local debug_track_module = "Module:debug/track"
| |
| local gender_and_number_module = "Module:getn" | | local gender_and_number_module = "Module:getn" |
| local headword_data_module = "Module:headword/data" | | local headword_data_module = "Module:headword/data" |
| Line 47: |
Line 46: |
| return (rsubn(term, foo, bar)) | | return (rsubn(term, foo, bar)) |
| end | | end |
|
| |
| -- Add a tracking category to track entries with certain (unusually undesirable) properties. `track_id` is an identifier
| |
| -- for the particular property being tracked and goes into the tracking page. Specifically, this adds a link in the
| |
| -- page text to [[Wiktionary:Tracking/headword/TRACK_ID]], meaning you can find all entries with the `track_id` property
| |
| -- by visiting [[Special:WhatLinksHere/Wiktionary:Tracking/headword/TRACK_ID]].
| |
| --
| |
| -- If `lang` (a language object) is given, an additional tracking page [[Wiktionary:Tracking/headword/TRACK_ID/CODE]] is
| |
| -- linked to where CODE is the language code of `lang`, and you can find all entries in the combination of `track_id`
| |
| -- and `lang` by visiting [[Special:WhatLinksHere/Wiktionary:Tracking/headword/TRACK_ID/CODE]]. This makes it possible to
| |
| -- isolate only the entries with a specific tracking property that are in a given language. Note that if `lang`
| |
| -- references at etymology-only language, both that language's code and its full parent's code are tracked.
| |
| local function track(track_id, lang)
| |
| local tracking_page = "headword/" .. track_id
| |
| local m_debug_track = require(debug_track_module)
| |
| if lang and lang:hasType("etymology-only") then
| |
| m_debug_track{tracking_page, tracking_page .. "/" .. lang:getCode(),
| |
| tracking_page .. "/" .. lang:getFullCode()}
| |
| elseif lang then
| |
| m_debug_track{tracking_page, tracking_page .. "/" .. lang:getCode()}
| |
| else
| |
| m_debug_track(tracking_page)
| |
| end
| |
| return true
| |
| end
| |
|
| |
|
| |
|
| local function text_in_script(text, script_code) | | local function text_in_script(text, script_code) |
| Line 269: |
Line 243: |
| else | | else |
| head_parts = concat(head_parts) | | head_parts = concat(head_parts) |
| end
| |
|
| |
| if has_manual_translits then
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/has-manual-translit]]
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/has-manual-translit/LANGCODE]]
| |
| track("has-manual-translit", data.lang)
| |
| end | | end |
|
| |
|
| Line 306: |
Line 274: |
|
| |
|
| if transliteration_page and transliteration_page.exists then | | if transliteration_page and transliteration_page.exists then |
| translits_formatted = " [[Wiktionary:" .. langname .. " transliteration|•]]" .. translits_formatted | | translits_formatted = " [[" .. langname .. " transliteration|•]]" .. translits_formatted |
| saw_translit_page = true | | saw_translit_page = true |
| end | | end |
| Line 316: |
Line 284: |
| | | |
| if transliteration_page and transliteration_page.exists then | | if transliteration_page and transliteration_page.exists then |
| translits_formatted = " [[Wiktionary:" .. langname .. " transliteration|•]]" .. translits_formatted | | translits_formatted = " [[" .. langname .. " transliteration|•]]" .. translits_formatted |
| end | | end |
| end | | end |
| Line 379: |
Line 347: |
| -- right into the 'data' table to disable inflection links of the entire headword | | -- right into the 'data' table to disable inflection links of the entire headword |
| -- when inflected forms aren't entry-worthy, e.g.: in Vulgar Latin | | -- when inflected forms aren't entry-worthy, e.g.: in Vulgar Latin |
| local nolinkinfl = part.face == "hypothetical" or (part.nolink and track("nolink") or part.nolinkinfl) or ( | | local nolinkinfl = part.face == "hypothetical" or part.nolinkinfl or data.nolinkinfl |
| data.nolink and track("nolink") or data.nolinkinfl)
| |
|
| |
|
| local formatted | | local formatted |
| Line 682: |
Line 649: |
| local escaped_langname = pattern_escape(full_langname) | | local escaped_langname = pattern_escape(full_langname) |
| local matches_lang_pattern = "^" .. escaped_langname .. " " | | local matches_lang_pattern = "^" .. escaped_langname .. " " |
| for _, cat in ipairs(data.categories) do
| |
| -- Does the category begin with the language name? If not, tag it with a tracking category.
| |
| if not cat:find(matches_lang_pattern) then
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/no lang category]]
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/no lang category/LANGCODE]]
| |
| track("no lang category", data.lang)
| |
| end
| |
| end
| |
|
| |
|
| -- If `pos_category` not given, try to infer it from the first specified category. If this doesn't work, we | | -- If `pos_category` not given, try to infer it from the first specified category. If this doesn't work, we |
| Line 720: |
Line 679: |
| -- add an appropriate category. | | -- add an appropriate category. |
| local postype = export.pos_lemma_or_nonlemma(data.pos_category) | | local postype = export.pos_lemma_or_nonlemma(data.pos_category) |
| if not postype then
| | if not data.noposcat then |
| -- We don't know what this category is, so tag it with a tracking category.
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/unrecognized pos]]
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/unrecognized pos/LANGCODE]]
| |
| track("unrecognized pos", data.lang)
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/unrecognized pos/POS]]
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/unrecognized pos/POS/LANGCODE]]
| |
| track("unrecognized pos/pos/" .. data.pos_category, data.lang)
| |
| elseif not data.noposcat then
| |
| insert(data.categories, 1, full_langname .. " " .. postype .. "s") | | insert(data.categories, 1, full_langname .. " " .. postype .. "s") |
| end | | end |
| Line 924: |
Line 875: |
|
| |
|
| ------------ 8. Insert additional categories. ------------ | | ------------ 8. Insert additional categories. ------------ |
|
| |
| if data.force_cat_output then
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/force cat output]]
| |
| track("force cat output")
| |
| end
| |
|
| |
|
| if has_redundant_head_param then | | if has_redundant_head_param then |
| Line 1,153: |
Line 1,099: |
| if page.namespace == "" and not data.lang:hasType("reconstructed") then | | if page.namespace == "" and not data.lang:hasType("reconstructed") then |
| local m_links = require(links_module) | | local m_links = require(links_module) |
| for _, head in ipairs(data.heads) do
| |
| if page.full_raw_pagename ~= m_links.get_link_page(remove_links(head.term), data.lang, head.sc) then
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/pagename spelling mismatch]]
| |
| -- [[Special:WhatLinksHere/Wiktionary:Tracking/headword/pagename spelling mismatch/LANGCODE]]
| |
| track("pagename spelling mismatch", data.lang)
| |
| break
| |
| end
| |
| end
| |
| end | | end |
|
| |
|