Module:sl-headword
- The following documentation is located at Module:sl-headword/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module is used for all Slovene headword-line templates. It provides a basic functionality common to all of them, but some of the templates have specific additional functionality to show genders or inflected forms.
Accented headwords
All Slovene headword-line templates use the first parameter to provide the headword, with accented vowels where present. This uses the tonal diacritics. See Appendix:Slovene pronunciation and Wiktionary:About Slovene for more details. For example:
{{sl-noun|jẹ̄ž|m-an}}
{{sl-adj|nȍv|novȇjši}}
{{sl-pron|óna}}
If the word can be accented in more than one way, use additional |head2=
, |head3=
(etc.) parameters. For example on takoj:
{{sl-adv|takọ̑j|head2=takȍj}}
The headword parameter works exactly like |head=
on the {{head}}
template, so it supports all the same special features. You can therefore also use this parameter to link to individual words of a multi-word term. These words can be linked with accents still in place; the module will remove them from the page name before creating a link, much like {{l}}
does.
All Slovene words are expected to have accents specified. The module will check the parameter for the presence of accents, and categorize the entry in Category:Requests for accents in Slovene entries if none are found. Some words like prepositions really have no inherent accent of their own. For such words, give -
as the first parameter, as on the preposition brez:
{{sl-prep|-}}
This tells the module that you are sure that the word should not have accents, so that it will not check for them.
If you don't know where to place the accents, you can leave the parameter empty, or just write the page name without accents. Don't use -
unless you're sure the word should not have any accents.
local m_params = require("Module:parameters")
local m_str_utils = require("Module:string utilities")
local find = m_str_utils.find
local lower = m_str_utils.lower
local u = m_str_utils.char
local lang = require("Module:languages").getByCode("sl")
local export = {}
local function do_headwords(data)
-- If the first headword given is "-", then skip the check.
if data.heads[1] == "-" then
data.heads[1] = mw.title.getCurrentTitle().subpageText
return false
end
for i, head in ipairs(data.heads) do
if not require("Module:sl-common").has_accents(head) then
table.insert(data.categories, "Requests for accents in Slovene entries")
end
end
return true
end
local function do_genders(data)
local valid_genders = {
["m"] = true,
["m-an"] = true,
["m-in"] = true,
["f"] = true,
["n"] = true,
["m-d"] = true,
["f-d"] = true,
["n-d"] = true,
["m-p"] = true,
["f-p"] = true,
["n-p"] = true,
}
for i, g in ipairs(data.genders) do
data.genders[i] = g
-- Categorize by gender, in addition to what's done already by [[Module:gender and number]]
if g == "m-an" then
table.insert(data.categories, "Slovene masculine animate nouns")
elseif g == "m-in" then
table.insert(data.categories, "Slovene masculine inanimate nouns")
end
end
end
local function do_comparatives(data, comparatives, check_accents)
local SUBPAGENAME = mw.title.getCurrentTitle().subpageText
--local encoded_head = data.heads[1]
--if encoded_head == SUBPAGENAME then
-- encoded_head = nil
--end
local comp_parts = {label = "[[Appendix:Glossary#comparative|comparative]]", request = true} --accel = {form = "comparative", lemma = encoded_head}
local sup_parts = {label = "[[Appendix:Glossary#superlative|superlative]]"} --accel = {form = "superlative", lemma = encoded_head}
for i, comp in ipairs(comparatives) do
if comp == "bolj" then
table.insert(comp_parts, "[[bȍlj]] " .. (data.heads[1] or SUBPAGENAME))
table.insert(sup_parts, "[[nȁjbolj]] " .. (data.heads[1] or SUBPAGENAME))
else
table.insert(comp_parts, comp)
table.insert(sup_parts, "nȁj" .. comp)
if check_accents and not require("Module:sl-common").has_accents(comp) then
table.insert(data.categories, "Requests for accents in Slovene entries")
end
end
end
table.insert(data.inflections, comp_parts)
table.insert(data.inflections, sup_parts)
end
function export.default(frame)
local params = {
[1] = {list = "head"},
}
local args = m_params.process(frame:getParent().args, params, nil, "sl-headword", "default")
local data = {lang = lang, pos_category = frame.args[1], categories = {}, heads = args[1], inflections = {}}
local check_accents = do_headwords(data)
return require("Module:headword").full_headword(data)
end
function export.adjectives(frame)
local params = {
[1] = {list = "head"},
[2] = {list = true},
}
local args = m_params.process(frame:getParent().args, params, nil, "sl-headword", "adjectives")
local data = {lang = lang, pos_category = "adjectives", categories = {}, heads = args[1], inflections = {}}
local check_accents = do_headwords(data)
-- Decide what to do next...
if args[2][1] == "-" then
table.insert(data.inflections, {label = "not [[Appendix:Glossary#comparable|comparable]]"})
else
do_comparatives(data, args[2], check_accents)
end
return require("Module:headword").full_headword(data)
end
function export.adverbs(frame)
local params = {
[1] = {list = "head"},
[2] = {list = true},
}
local args = m_params.process(frame:getParent().args, params, nil, "sl-headword", "adverbs")
local data = {lang = lang, pos_category = "adverbs", categories = {}, heads = args[1], inflections = {}}
local check_accents = do_headwords(data)
-- Decide what to do next...
if args[2][1] and args[2][1] ~= "-" then
do_comparatives(data, args[2], check_accents)
end
return require("Module:headword").full_headword(data)
end
function export.nouns(frame)
local params = {
[1] = {list = "head"},
[2] = {list = "g", default = "?"},
["f"] = {list = true},
["m"] = {list = true},
}
local args = m_params.process(frame:getParent().args, params, nil, "sl-headword", "nouns")
local data = {lang = lang, pos_category = "nouns", categories = {}, heads = args[1], genders = args[2], inflections = {}}
local check_accents = do_headwords(data)
do_genders(data)
-- Female equivalent
if #args["f"] > 0 then
args["f"].label = "female equivalent"
if check_accents then
for i, form in ipairs(args["f"]) do
if not require("Module:sl-common").has_accents(form) then
table.insert(data.categories, "Requests for accents in Slovene noun entries")
end
end
end
-- Tone check
for i, form in ipairs(args["f"]) do
local found_tonal = false
local found_stress = false
local found_ambiguous = false
form = lower(form)
if find(form, "[ȃȇȋȏȗȓāēīōūȁȅȉȍȕẹọ" .. u(0x0304) .. "]") then
found_tonal = true
end
if find(form, "[êô]") then
found_stress = true
end
if find(form, "[áéíóúŕàèìòù]") then
found_ambiguous = true
end
if found_stress then
require("Module:debug").track("sl-headword/stress")
elseif found_ambiguous then
require("Module:debug").track("sl-headword/ambiguous")
elseif found_tonal then
require("Module:debug").track("sl-headword/tonal")
end
end
table.insert(data.inflections, args["f"])
end
-- Male equivalent
if #args["m"] > 0 then
args["m"].label = "male equivalent"
if check_accents then
for i, form in ipairs(args["m"]) do
if not require("Module:sl-common").has_accents(form) then
table.insert(data.categories, "Requests for accents in Slovene noun entries")
end
end
end
-- Tone check
for i, form in ipairs(args["m"]) do
local found_tonal = false
local found_stress = false
local found_ambiguous = false
form = lower(form)
if find(form, "[ȃȇȋȏȗȓāēīōūȁȅȉȍȕẹọ" .. u(0x0304) .. "]") then
found_tonal = true
end
if find(form, "[êô]") then
found_stress = true
end
if find(form, "[áéíóúŕàèìòù]") then
found_ambiguous = true
end
if found_stress then
require("Module:debug").track("sl-headword/stress")
elseif found_ambiguous then
require("Module:debug").track("sl-headword/ambiguous")
elseif found_tonal then
require("Module:debug").track("sl-headword/tonal")
end
end
table.insert(data.inflections, args["m"])
end
return require("Module:headword").full_headword(data)
end
function export.proper_nouns(frame)
local params = {
[1] = {list = "head"},
[2] = {list = "g", default = "?"},
["f"] = {list = true},
}
local args = m_params.process(frame:getParent().args, params, nil, "sl-headword", "proper_nouns")
local data = {lang = lang, pos_category = "proper nouns", categories = {}, heads = args[1], genders = args[2], inflections = {}}
local check_accents = do_headwords(data)
do_genders(data)
-- Female equivalent
if #args["f"] > 0 then
args["f"].label = "female equivalent"
if check_accents then
for i, form in ipairs(args["f"]) do
if not require("Module:sl-common").has_accents(form) then
table.insert(data.categories, "Requests for accents in Slovene noun entries")
end
end
end
table.insert(data.inflections, args["f"])
end
return require("Module:headword").full_headword(data)
end
function export.verbs(frame)
local params = {
[1] = {list = "head"},
[2] = {default = "?"},
["impf"] = {list = true},
["pf"] = {list = true},
}
local args = m_params.process(frame:getParent().args, params, nil, "sl-headword", "verbs")
local data = {lang = lang, pos_category = "verbs", categories = {}, heads = args[1], genders = {args[2]}, inflections = {}}
local check_accents = do_headwords(data)
-- Check aspect
if data.genders[1] == "impf" then
table.insert(data.categories, "Slovene imperfective verbs")
if #args["impf"] > 0 then
error("Imperfective verbs cannot have an imperfective equivalent")
end
-- Perfective equivalents
if #args["pf"] > 0 then
if check_accents then
for _, form in ipairs(args["pf"]) do
if require("Module:sl-common").has_accents(form) then
table.insert(data.categories, "Requests for accents in Slovene verb entries")
end
end
end
args["pf"].label = "perfective"
table.insert(data.inflections, args["pf"])
end
elseif data.genders[1] == "pf" then
table.insert(data.categories, "Slovene perfective verbs")
if #args["pf"] > 0 then
error("Perfective verbs cannot have a perfective equivalent")
end
-- Imperfective equivalents
if #args["impf"] > 0 then
if check_accents then
for _, form in ipairs(args["impf"]) do
if require("Module:sl-common").has_accents(form) then
table.insert(data.categories, "Requests for accents in Slovene verb entries")
end
end
end
args["impf"].label = "imperfective"
table.insert(data.inflections, args["impf"])
end
elseif data.genders[1] == "both" then
data.genders = {"impf", "pf"}
table.insert(data.categories, "Slovene biaspectual verbs")
if #args["impf"] > 0 or #args["pf"] > 0 then
error("Bispectual verbs cannot have an imperfective or perfective equivalent")
end
else
data.genders = {"?"}
table.insert(data.categories, "Requests for aspect in Slovene entries")
end
return require("Module:headword").full_headword(data)
end
return export