Modul:ko-headword
Bu modul uchun Modul:ko-headword/doc nomli hujjat sahifasini yaratishingiz mumkin
local m_translit = require("Module:ko-translit")
local function ucfirst(s)
-- Birinchi harfi bilan belgilangan magʻlubiyatga kapitalizasiya qaytaradi.
-- Non-ASCII satrlari bilan foydalanish uchun emas, balki.
return s:sub(1, 1):upper() .. s:sub(2, -1)
end
local export = {}
local pos_functions = {}
local tili = require("Module:tili").getByCode("ko")
pos_functions["feʼli"] = function(args, inflections, categories)
-- infinitive(s)
local hae = args["hae"]; if hae == "" then hae = nil end
local hae2 = args["hae2"]; if hae2 == "" then hae2 = nil end
local infinitives = {label = "noaniq"}
if hae then table.insert(infinitives, hae) end
if hae2 then table.insert(infinitives, hae2) end
if #infinitives > 0 then table.insert(inflections, infinitives) end
-- sequential
local hani = args["hani"]; if hani == "" then hani = nil end
if hani then table.insert(inflections, {label = "sequential", hani}) end
end
-- same as verbs above
pos_functions["sifat"] = pos_functions["feʼli"]
-- same as verbs above
pos_functions["suffixes"] = pos_functions["feʼli"]
pos_functions["sifat shakllar"] = function(args, inflections, categories)
local root = args["root"]; if root == "" then root = nil end
local form = args["form"]; if form == "" then form = nil end
if form and root then
table.insert(inflections, {label = form .. " of", root})
end
end
pos_functions["huquqbuzarlik shakllari"] = pos_functions["sifat shakllar"]
pos_functions["determiners"] = function(args, inflections, categories)
local root = args["root"]; if root == "" then root = nil end
if root then table.insert(inflections, {label = "determinative form of", root}) end
end
pos_functions["ot"] = function(args, inflections, categories)
local count = args["count"]; if count == "" then count = nil end
if count == '-' then
table.insert(inflections, "sonsiz")
elseif count then
table.insert(inflections, {label = "counter", count})
end
end
-- other parts of speech: nothing special is done for adverbs, interjections, suffixes
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
PAGENAME = mw.title.getCurrentTitle().text
local args = frame:getParent().args
local poscat = frame.args[1] or error("Nutq qismi belgilangan olinmagan. Moduli nolish uchun parametrni 1 oʻtishi qiling.")
local categories = {}
local inflections = {}
local transliterations = {}
local hangeul_pattern = '[가-힣 ]' -- includes a space character too
local hanja_pattern = '[一-鿌]'
local head = args["bosh"]; if head == "" then head = nil end
-- grammatical forms etc. for each respective part of speech
if pos_functions[poscat] then
pos_functions[poscat](args, inflections, categories)
end
-- Different script forms
local hangeul = args["hangeul"]; if hangeul == "" then hangeul = nil end
local hanja = args["hanja"]; if hanja == "" then hanja = nil end
-- Different romanizations
-- revised romanization could be rv or rr
local rv = args["rv"] or args["rr"]; if rv == "" then rv = nil end
local mr = args["mr"]; if mr == "" then mr = nil end
local y = args["y"]; if y == "" then y = nil end
-- >>> transliterations <<<
-- if this entry is hangeul and no transliteration is provided, add auto transliteration
-- if this entry is NOT hangeul and no translit is provided, add auto translit if there is hangeul
if mw.ustring.gsub(PAGENAME, hangeul_pattern, '') == "" and rv == nil then
rv = m_translit.tr(PAGENAME)
elseif hangeul and rv == nil then
rv = m_translit.tr(hangeul) end
if poscat == 'atoqli ot' then
rv = mw.ustring.upper(mw.ustring.sub(rv,1,1)) .. mw.ustring.sub(rv,2,-1)
end
-- add -hada to the revised romanization for 하다 (hada) verbs
if poscat == "hada feʼli soʻzlari" then
rv = rv .. "-hada"
head = PAGENAME .. " + 하다"
end
if rv then table.insert(transliterations, rv) end
if mr then table.insert(transliterations, "McCune-Reischauer: " .. mr) end
if y then table.insert(transliterations, "Yale: " .. y) end
if hangeul then
table.insert(inflections, {label = "hangeul", hangeul})
end
if hanja then
table.insert(inflections, {label = "hanja", hanja})
end
-- categorize by part of speech
if poscat == "hada feʼli soʻzlari" then
table.insert(categories, "Koreyschada feʼli soʻzlari")
table.insert(categories, "Koreyschada hada feʼli soʻzlari")
elseif poscat == "yordamchi feʼllar" then
table.insert(categories, "Koreyschada feʼli soʻzlari")
table.insert(categories, "Koreyscha yordamchi feʼllar")
else
table.insert(categories, "Koreyschada " .. poscat)
end
-- and categorize hanja terms
if mw.ustring.match(PAGENAME, hanja_pattern) then
table.insert(categories, "Koreyscha Han belgilar")
if poscat == "ot" then
table.insert(categories, "Han skript koreyscha maʼnoga ega boʻlgan moddalar")
elseif poscat == "atoqli ot" then
table.insert(categories, "Han buyruq koreyscha toʻgʻri maʼnoga ega boʻlgan moddalar")
end
end
-- maintenance category for hanja terms without hangeul
if mw.ustring.match(PAGENAME, hanja_pattern) and hangeul == nil then
table.insert(categories, "Hangeul yoʻq koreyscha Hanja shartlari") end
return require("Module:headword").full_headword(lang, nil, head, table.concat(transliterations, ", "), nil, inflections, categories, hangeul)
end
return export