Module:Sl-headword
local m_common = require("Module:sl-common")
local export = {}
local lang = require("Module:languages").getByCode("sl")
local pos_functions = {}
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local args = frame:getParent().args
PAGENAME = mw.title.getCurrentTitle().text
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local data = {lang = lang, pos_category = poscat, categories = {}, heads = {args[1] or ""}, genders = {}, inflections = {}}
-- Gather headwords
local i = 2
local head = args["head" .. i]
while head do
if head ~= "" then
table.insert(data.heads, head)
end
i = i + 1
head = args["head" .. i]
end
-- Process headwords for accents
local check_accents = true
-- If the first headword given is "-", then skip the check.
if data.heads[1] == "-" then
data.heads[1] = ""
check_accents = false
else
for i, head in ipairs(data.heads) do
if head == "" or not m_common.has_accents(head) then
table.insert(data.categories, "Slovene terms needing accents")
end
end
end
-- Call POS-specific function
if pos_functions[poscat] then
pos_functions[poscat](args, data, check_accents)
end
return require("Module:headword").full_headword(data)
end
-- Display additional inflection information for an adjective
pos_functions["adjectives"] = function(args, data, check_accents)
-- Get all the parameters
local comparatives = {}
local i = 2
while true do
local comp = args[i]; if comp == "" then comp = nil end
if not comp then
break
end
table.insert(comparatives, comp)
i = i + 1
end
-- Decide what to do next...
local mode = comparatives[1]
if mode == "-" then
table.insert(data.inflections, {label = "not [[Appendix:Glossary#comparable|comparable]]"})
else
do_comparatives(data, comparatives, check_accents)
end
end
-- Display additional inflection information for an adverb
pos_functions["adverbs"] = function(args, data, check_accents)
-- Get all the parameters
local comparatives = {}
local i = 2
while true do
local comp = args[i]; if comp == "" then comp = nil end
if not comp then
break
end
table.insert(comparatives, comp)
i = i + 1
end
-- Decide what to do next...
local mode = comparatives[1]
if mode and mode ~= "-" then
do_comparatives(data, comparatives, check_accents)
end
end
function do_comparatives(data, comparatives, check_accents)
local encoded_head = ""
if data.heads[1] ~= "" then
-- This is decoded again by [[WT:ACCEL]].
encoded_head = " origin-" .. data.heads[1]:gsub("%%", "."):gsub(" ", "_")
end
local comp_parts = {label = "[[Appendix:Glossary#comparative|comparative]]", accel = "comparative-form-of" .. encoded_head, request = true}
local sup_parts = {label = "[[Appendix:Glossary#superlative|superlative]]", accel = "superlative-form-of" .. encoded_head}
for i, comp in ipairs(comparatives) do
if comp == "bolj" then
table.insert(comp_parts, "[[bòlj]] " .. (data.heads[1] ~= "" and data.heads[1] or PAGENAME))
table.insert(sup_parts, "[[nàjbolj]] " .. (data.heads[1] ~= "" and data.heads[1] or PAGENAME))
else
table.insert(comp_parts, comp)
table.insert(sup_parts, "nàj" .. comp)
if check_accents and not m_common.has_accents(comp) then
table.insert(data.categories, "Slovene terms needing accents")
end
end
end
table.insert(data.inflections, comp_parts)
table.insert(data.inflections, sup_parts)
end
-- Display additional inflection information for a noun
pos_functions["nouns"] = function(args, data, check_accents)
pos_functions["proper nouns"](args, data, check_accents)
-- If the noun is a duale/plurale tantum, then ignore the 4th parameter altogether
local num = data.genders[1]:sub(3,3)
if num == "d" then
table.insert(data.inflections, {label = "[[Appendix:Glossary#duale tantum|duale tantum]]"})
elseif num == "p" then
table.insert(data.inflections, {label = "[[Appendix:Glossary#plurale tantum|plurale tantum]]"})
else
-- Get the plural parameters
-- First get the 4th parameter. The remainder is named pl2=, pl3= etc.
local form = args[4]; if form == "" then form = nil end
local plurals = {form}
local i = 2
while true do
form = args["pl" .. i]; if form == "" then form = nil end
if not form then
break
end
table.insert(plurals, form)
i = i + 1
end
-- Decide what to do next...
local mode = plurals[1]
if mode == "-" then
table.insert(data.inflections, {label = "[[Appendix:Glossary#uncountable|uncountable]]"})
table.insert(data.categories, "Slovene uncountable nouns")
else
plurals.label = "nominative plural"
plurals.request = true
for i, form in ipairs(plurals) do
if check_accents and not m_common.has_accents(form) then
table.insert(data.categories, "Slovene nouns needing accents")
end
end
table.insert(data.inflections, plurals)
end
end
-- Get the feminine parameters
-- First get the f= parameter. The remainder is named f2=, f3= etc.
local form = args["f"]; if form == "" then form = nil end
local feminines = {form}
local i = 2
while true do
form = args["f" .. i]; if form == "" then form = nil end
if not form then
break
end
table.insert(feminines, form)
i = i + 1
end
if #feminines > 0 then
local f_parts = {label = "feminine"}
for i, form in ipairs(feminines) do
table.insert(f_parts, form)
if check_accents and not m_common.has_accents(form) then
table.insert(data.categories, "Slovene nouns needing accents")
end
end
table.insert(data.inflections, f_parts)
end
-- Get the masculine parameters
-- First get the m= parameter. The remainder is named m2=, m3= etc.
local form = args["m"]; if form == "" then form = nil end
local masculines = {form}
local i = 2
while true do
form = args["m" .. i]; if form == "" then form = nil end
if not form then
break
end
table.insert(masculines, form)
i = i + 1
end
if #masculines > 0 then
local m_parts = {label = "masculine"}
for i, form in ipairs(masculines) do
table.insert(m_parts, form)
if check_accents and not m_common.has_accents(form) then
table.insert(data.categories, "Slovene nouns needing accents")
end
end
table.insert(data.inflections, m_parts)
end
end
-- Display additional inflection information for a proper noun
-- This is also used for nouns
pos_functions["proper nouns"] = function(args, data, check_accents)
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 }
-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
local g = args[2]; if g == "" then g = nil end
local i = 2
while g do
if g == "m" then g = "m-?" end
if not valid_genders[g] then
g = "?"
end
table.insert(data.genders, g)
-- Categorize by gender
if g == "m-an" then
table.insert(data.categories, "Slovene masculine nouns")
table.insert(data.categories, "Slovene masculine animate nouns")
elseif g == "m-in" then
table.insert(data.categories, "Slovene masculine nouns")
table.insert(data.categories, "Slovene masculine inanimate nouns")
elseif g:sub(1,1) == "m" then
table.insert(data.categories, "Slovene masculine nouns")
elseif g:sub(1,1) == "f" then
table.insert(data.categories, "Slovene feminine nouns")
elseif g:sub(1,1) == "n" then
table.insert(data.categories, "Slovene neuter nouns")
end
-- Categorize by number
if g:sub(3,3) == "d" then
table.insert(data.categories, "Slovene dualia tantum")
elseif g:sub(3,3) == "p" then
table.insert(data.categories, "Slovene pluralia tantum")
end
g = args["g" .. i]; if g == "" then g = nil end
i = i + 1
end
if #data.genders == 0 then
table.insert(data.genders, "?")
elseif #data.genders > 1 then
table.insert(data.categories, "Slovene nouns with multiple genders")
end
-- Get the genitive parameters
-- First get the 3rd parameter. The remainder is named gen2=, gen3= etc.
local form = args[3]; if form == "" then form = nil end
local genitives = {form}
local i = 2
while true do
form = args["gen" .. i]; if form == "" then form = nil end
if not form then
break
end
table.insert(genitives, form)
i = i + 1
end
-- Show the forms
genitives.label = "genitive"
genitives.request = true
for i, form in ipairs(genitives) do
if check_accents and not m_common.has_accents(form) then
table.insert(data.categories, "Slovene nouns needing accents")
end
end
table.insert(data.inflections, genitives)
end
-- Display additional inflection information for a verb
pos_functions["verbs"] = function(args, data, check_accents)
-- Aspect
local aspect = args[2]; if aspect == "" then aspect = nil end
if aspect == "impf" then
table.insert(data.genders, "impf")
table.insert(data.categories, "Slovene imperfective verbs")
elseif aspect == "pf" then
table.insert(data.genders, "pf")
table.insert(data.categories, "Slovene perfective verbs")
elseif aspect == "both" then
table.insert(data.genders, "impf")
table.insert(data.genders, "pf")
table.insert(data.categories, "Slovene imperfective verbs")
table.insert(data.categories, "Slovene perfective verbs")
else
table.insert(data.genders, "?")
table.insert(data.categories, "Slovene verbs needing aspect")
end
-- Get all the parameters
-- First get the 3rd and 4th parameters. The remainder is named pres2=, past2= etc.
local pres = args[3]; if pres == "" then pres = nil end
local past = args[4]; if past == "" then past = nil end
local presents = {pres}
local pasts = {past}
local i = 2
while true do
pres = args["pres" .. i]; if pres == "" then pres = nil end
past = args["past" .. i]; if past == "" then past = nil end
if not pres and not past then
break
end
if pres then table.insert(presents, pres) end
if past then table.insert(pasts, past) end
i = i + 1
end
-- Present tense (1st person singular)
presents.label = "first-person singular present"
presents.request = true
for i, form in ipairs(presents) do
if check_accents and not m_common.has_accents(form) then
table.insert(data.categories, "Slovene verbs needing accents")
end
end
table.insert(data.inflections, presents)
-- Past tense (past active participle / l-participle)
pasts.label = "past active participle"
for i, form in ipairs(pasts) do
if check_accents and not m_common.has_accents(form) then
table.insert(data.categories, "Slovene verbs needing accents")
end
end
table.insert(data.inflections, pasts)
end
return export
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.