A modult a Modul:bg-headword/doc lapon tudod dokumentálni
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("bg")
local rfind = mw.ustring.find
local rsubn = mw.ustring.gsub
-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
local retval = rsubn(term, foo, bar)
return retval
end
local function track(page)
require("Module:debug").track("bg-headword/" .. page)
return true
end
local function format(array, concatenater)
if #array == 0 then
return ""
else
local concatenated = table.concat(array, concatenater)
if concatenated == "" then
return ""
elseif rfind(concatenated, "'$") then
concatenated = concatenated .. " "
end
return "; ''" .. concatenated .. "''"
end
end
local function glossary_link(anchor, text)
text = text or anchor
return "]"
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local NAMESPACE = mw.title.getCurrentTitle().nsText
local PAGENAME = mw.title.getCurrentTitle().text
local iparams = {
= {required = true},
= {},
= {},
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local args = frame:getParent().args
local poscat = iargs
local def = iargs.def
local suff_type = iargs.suff_type
local postype = nil
if suff_type then
postype = poscat .. '-' .. suff_type
else
postype = poscat
end
local data = {lang = lang, categories = {}, heads = {}, genders = {}, inflections = {}}
if poscat == "suffixes" then
table.insert(data.categories, "Bulgarian " .. suff_type .. "-forming suffixes")
end
if pos_functions then
local new_poscat = pos_functions(postype, def, args, data)
if new_poscat then
poscat = new_poscat
end
end
if not rfind(poscat, " forms?$") then
for _, head in ipairs(data.heads) do
-- Don't trigger on prefixes or suffixes.
if (rfind(head, " ") or rfind(head, ".%-.")) and not rfind(head, "^+ с$") then
table.insert(data.categories, "Bulgarian multiword terms")
break
end
end
end
data.pos_category = (NAMESPACE == "Reconstruction" and "reconstructed " or "") .. poscat
return require("Module:headword").full_headword(data)
end
pos_functions = function(postype, def, args, data)
local params = {
= {required = true, list = "head"},
= {},
= {list = true, allow_holes = true},
= {list = true},
= {list = true},
= {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.translits = args.tr
data.id = args.id
if args == "pf" then
data.genders = {"pf"}
elseif args == "impf" then
data.genders = {"impf"}
elseif args == "both" then
data.genders = {"impf", "pf"}
elseif args then
error("Unrecognized aspect '" .. args .. "'")
end
local pf = args.pf
if #pf > 0 then
pf.label = "perfective"
table.insert(data.inflections, pf)
end
local impf = args.impf
if #impf > 0 then
impf.label = "imperfective"
table.insert(data.inflections, impf)
end
end
local function nouns(pos, def, args, data)
local params = {
= {required = true, list = "head"},
= {list = true, allow_holes = true},
= {alias_of = "g"},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
= {list = true},
= {},
= {type = "boolean"},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.translits = args.tr
local genders = {}
local cat2 = nil
for _, g in ipairs(args.g) do
if g == "m" or g == "m-p" then
cat2 = "Bulgarian masculine nouns"
elseif g == "f" or g == "f-p" then
cat2 = "Bulgarian feminine nouns"
elseif g == "n" or g == "n-p" then
cat2 = "Bulgarian neuter nouns"
elseif g ~= "p" then
error("Unrecognized gender: '" .. g .. "'")
end
table.insert(genders, g)
end
table.insert(data.categories, cat2)
if #genders > 1 then
table.insert(data.categories, "Bulgarian nouns with multiple genders")
end
data.genders = genders
if args.indecl then
table.insert(data.inflections, {label = "indeclinable"})
end
local m = args.m
if #m > 0 then
m.label = "masculine"
table.insert(data.inflections, m)
end
local f = args.f
if #f > 0 then
f.label = "feminine"
table.insert(data.inflections, f)
end
local adj = args.adj
if #adj > 0 then
adj.label = "related adjective"
table.insert(data.inflections, adj)
end
local dim = args.dim
if #dim > 0 then
dim.label = "diminutive"
table.insert(data.inflections, dim)
end
data.id = args.id
end
pos_functions = nouns
pos_functions = nouns
local function adverbs(pos, def, args, data)
local params = {
= {required = true, list = "head"},
= {list = true, allow_holes = true},
= {alias_of = "comp"},
= {list = true},
= {alias_of = "sup"},
= {list = true},
= {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.translits = args.tr
local comp = args.comp
if comp == "-" then
table.insert(data.inflections, {label = "no comparative"})
else
if #comp == 0 then
for _, head in ipairs(args) do
table.insert(comp, "по́-" .. head)
end
end
comp.label = "comparative"
table.insert(data.inflections, comp)
local sup = args.sup
if #sup == 0 then
for _, head in ipairs(args) do
table.insert(sup, "на́й-" .. head)
end
end
sup.label = "superlative"
table.insert(data.inflections, sup)
end
data.id = args.id
end
pos_functions = adverbs
local function adjectives(pos, def, args, data)
local params = {
= {required = true, list = "head"},
= {list = true, allow_holes = true},
= {list = true},
= {type = "boolean"},
= {list = true},
= {list = true},
= {list = true},
= {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.translits = args.tr
data.genders = args.g
if args.indecl then
table.insert(data.inflections, {label = "indeclinable"})
end
local dim = args.dim
if #dim > 0 then
dim.label = "diminutive"
table.insert(data.inflections, dim)
end
local adv = args.adv
if #adv > 0 then
adv.label = "adverb"
table.insert(data.inflections, adv)
end
local absn = args.absn
if #absn > 0 then
absn.label = "abstract noun"
table.insert(data.inflections, absn)
end
data.id = args.id
end
pos_functions = adjectives
pos_functions = adjectives
pos_functions = adjectives
pos_functions = function(postype, def, args, data)
return adjectives("suffixes", def, args, data)
end
pos_functions = function(postype, def, args, data)
return adjectives("numerals", def, args, data)
end
pos_functions = function(pos, def, args, data)
local params = {
= {required = true, list = "head"},
= {required = true, list = true, default = "aor"},
= {list = true, allow_holes = true},
= {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.translits = args.tr
data.genders = args.g
data.id = args.id
table.insert(data.categories, "Bulgarian verb forms")
for _, part in ipairs(args) do
if part == "adv" then
table.insert(data.categories, "Bulgarian adverbial participles")
elseif part == "aor" then
table.insert(data.categories, "Bulgarian past active aorist participles")
elseif part == "impf" then
table.insert(data.categories, "Bulgarian past active imperfect participles")
elseif part == "pres" then
table.insert(data.categories, "Bulgarian present active participles")
elseif part == "pass" or part == "ppp" then
table.insert(data.categories, "Bulgarian past passive participles")
elseif part == "prespass" then
table.insert(data.categories, "Bulgarian present passive participles")
else
error("Unrecognized participle type '" .. part .. "': Should be adv, aor, impf, pres, pass or prespass")
end
end
end
pos_functions = function(postype, def, args, data)
local params = {
= {required = true, list = "head", default = def},
= {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.id = args.id
end
local function non_lemma_forms(postype, def, args, data)
local params = {
= {required = true, list = "head", default = def},
= {list = true},
= {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args
data.genders = args.g
data.id = args.id
if postype == "participle forms" or postype == "verbal nouns" then
table.insert(data.categories, "Bulgarian verb forms")
elseif postype == "verbal noun forms" then
table.insert(data.categories, "Bulgarian verb forms")
return "noun forms"
end
end
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
pos_functions = non_lemma_forms
return export