A modult a Modul:sl-headword/doc lapon tudod dokumentálni
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 == "-" then
data.heads = ""
return false
end
for i, head in ipairs(data.heads) do
if head == "" or 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 = {
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
= true,
}
for i, g in ipairs(data.genders) do
if g == "m" then
g = "m-?"
elseif not valid_genders then
g = "?"
end
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
end
if #data.genders > 1 then
--table.insert(data.categories, "Slovene nouns with multiple genders")
end
end
local function do_comparatives(data, comparatives, check_accents)
local encoded_head = data.heads
if encoded_head == "" then
encoded_head = nil
end
local comp_parts = {label = "]", request = true} --accel = {form = "comparative", lemma = encoded_head}
local sup_parts = {label = "]"} --accel = {form = "superlative", lemma = encoded_head}
for i, comp in ipairs(comparatives) do
if comp == "bolj" then
table.insert(comp_parts, "] " .. (data.heads ~= "" and data.heads or mw.title.getCurrentTitle().text))
table.insert(sup_parts, "] " .. (data.heads ~= "" and data.heads or mw.title.getCurrentTitle().text))
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 = {
= {list = "head"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = frame.args, categories = {}, heads = args, inflections = {}}
local check_accents = do_headwords(data)
return require("Module:headword").full_headword(data)
end
function export.adjectives(frame)
local params = {
= {list = "head"},
= {list = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "melléknevek", categories = {}, heads = args, inflections = {}}
local check_accents = do_headwords(data)
-- Decide what to do next...
if args == "-" then
table.insert(data.inflections, {label = "nem ]"})
else
do_comparatives(data, args, check_accents)
end
return require("Module:headword").full_headword(data)
end
function export.adverbs(frame)
local params = {
= {list = "head"},
= {list = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "adverbs", categories = {}, heads = args, inflections = {}}
local check_accents = do_headwords(data)
-- Decide what to do next...
if args and args ~= "-" then
do_comparatives(data, args, check_accents)
end
return require("Module:headword").full_headword(data)
end
function export.nouns(frame)
local params = {
= {list = "head"},
= {list = "g", default = "?"},
= {list = true},
= {list = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "főnevek", categories = {}, heads = args, genders = args, inflections = {}}
local check_accents = do_headwords(data)
do_genders(data)
-- Female equivalent
if #args > 0 then
args.label = "female equivalent"
if check_accents then
for i, form in ipairs(args) 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) do
local found_tonal = false
local found_stress = false
local found_ambiguous = false
form = mw.ustring.lower(form)
if mw.ustring.find(form, "") then
found_tonal = true
end
if mw.ustring.find(form, "") then
found_stress = true
end
if mw.ustring.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)
end
-- Male equivalent
if #args > 0 then
args.label = "male equivalent"
if check_accents then
for i, form in ipairs(args) 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) do
local found_tonal = false
local found_stress = false
local found_ambiguous = false
form = mw.ustring.lower(form)
if mw.ustring.find(form, "") then
found_tonal = true
end
if mw.ustring.find(form, "") then
found_stress = true
end
if mw.ustring.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)
end
return require("Module:headword").full_headword(data)
end
function export.proper_nouns(frame)
local params = {
= {list = "head"},
= {list = "g", default = "?"},
= {list = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "tulajdonnevek", categories = {}, heads = args, genders = args, inflections = {}}
local check_accents = do_headwords(data)
do_genders(data)
-- Female equivalent
if #args > 0 then
args.label = "female equivalent"
if check_accents then
for i, form in ipairs(args) 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)
end
return require("Module:headword").full_headword(data)
end
function export.verbs(frame)
local params = {
= {list = "head"},
= {default = "?"},
= {list = true},
= {list = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "igék", categories = {}, heads = args, genders = {args}, inflections = {}}
local check_accents = do_headwords(data)
-- Check aspect
if data.genders == "impf" then
--table.insert(data.categories, "Slovene imperfective verbs")
if #args > 0 then
error("Imperfective verbs cannot have an imperfective equivalent")
end
-- Perfective equivalents
if #args > 0 then
if check_accents then
for _, form in ipairs(args) 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.label = "perfective"
table.insert(data.inflections, args)
end
elseif data.genders == "pf" then
--table.insert(data.categories, "Slovene perfective verbs")
if #args > 0 then
error("Perfective verbs cannot have a perfective equivalent")
end
-- Imperfective equivalents
if #args > 0 then
if check_accents then
for _, form in ipairs(args) 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.label = "imperfective"
table.insert(data.inflections, args)
end
elseif data.genders == "both" then
data.genders = {"impf", "pf"}
--table.insert(data.categories, "Slovene biaspectual verbs")
if #args > 0 or #args > 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