Module:User:Oyunqi/ug-headword

local export = {} local vowels = "اەېىوۇۆۈ" -- A list of functions that do the work that is specific to each part of speech. local pos_functions = {} local m_translit = require("Module:ug-translit") local lang = require("Module:languages").getByCode("ug")

-- 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 str = args["s"] or "" if str == "" then str = PAGENAME end local head = args["head"]; if head == "" then head = nil end -- The part of speech. This is also the name of the category that entries go in. local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.") -- Detect the script local sc = require("Module:scripts").findBestScript(str, lang) local tr = nil -- Generate or retrieve the transliteration, depending on the script. if sc == "Arab" then tr = m_translit.tr(str) end local data = {lang = lang, sc = sc, pos_category = poscat, categories = {}, heads = {head}, translits = {tr}, inflections = {}} if pos_functions[poscat] then pos_functions[poscat](args, data) end return require("Module:headword").full_headword(data) end

pos_functions["nouns"] = function(args, data) local plural = args["pl"]; local lastv2 = args[1] or ""; local lastc2 = args[2] or ""; if plural == "" or plural == nil then fixed, lastv, lastc = mw.ustring.match(str, "(.-)([" .. vowels .. "]+)([^" .. vowels .. "]-)$")		plural = getPlural(fixed, lastv, lastc, lastv2, lastc2) end if plural then local pl_tr = m_translit.tr(plural) local pl = {term = plural, translit = pl_tr} table.insert(data.inflections, {label = "plural", pl}) end end

getPlural = function(fixed,lastv,lastc,lastv2,lastc2) plural = "" if lastc == "" then if lastv == "ا" then if lastv2 == "" then lastv2 = "ى" end plural = fixed .. lastv2 .. "لار" elseif lastv == "ە" then if lastv2 == "" then lastv2 = "ى" end plural = fixed .. lastv2 .. "لەر" else -- todo plural = fixed .. lastv .. "لەر" end else if lastv == "ا" or lastv == "و" or lastv == "ۇ" then plural = fixed .. lastv2 .. lastc .. "لار" elseif lastv == "ە" or lastv == "ۆ" or lastv == "ۈ" then plural = fixed .. lastv2 .. lastc .. "لەر" else -- todo tillar, biller, sirlar, sizler plural = fixed .. lastv .. lastc .. "لەر" end end return plural end

return export