Module:ug-decl-noun

local export = {} local m_com = require("Module:ug-common") local m_case = require("Module:ug-noun") local lang = require("Module:languages").getByCode("ug") local m_links = require("Module:links") --local m_utilities = require("Module:utilities")

local match = mw.ustring.match

local PAGENAME = mw.title.getCurrentTitle.text

function export.get_args(frame) local args if frame.args["test"] then args = frame.args else args = frame:getParent.args end end function export.get_word(frame) local args if frame.args["test"] then args = frame.args else args = frame:getParent.args end local vv = args[1] local str = args["head"] or PAGENAME local base, v, c = m_com.getLast(str) if not v then return {} end local tongue = nil local v1 = v; v2 = v; c1 = c; c2 = c	local categories = {} if vv then if (vv == "ا" or vv == "ە") and (v == "ې" or v == "ى") then if vv == "ا" then tongue = "back" end if vv == "ە" then tongue = "front" end else if c == "" then -- open if (v == "ا" or v == "ە") then v1 = vv		   		if (vv == "ا" or vv == "ە") then c2 = "ي" table.insert(categories, "Uyghur nouns ending in " .. v .. " with no change") else table.insert(categories, "Uyghur nouns ending in " .. v .. " change to " .. vv) end elseif (v == "ې" or v == "ى") then v2 = vv table.insert(categories, "Uyghur nouns ending in " .. v .. " change to " .. vv) else v2 = vv; c2 = "ي" end else --close if (v == "ا" or v == "ە") then v2 = vv		   	elseif vv == "-" then v2 = "" end end end else if c == "" and not (v == "ې" or v == "ى") then -- open c2 = "ي" end end if not tongue then tongue = m_com.checkTongue(str) end --alll params local ae, iuu local ghqgk, ghg, dt	local consonJsiz = "پتچخسشفقكھ" local consonJliqSpecial = "غگبد" if tongue == "front" or tongue == "f" then ae = "ە" ghg = "گ" if match(c, "[" .. consonJsiz .. consonJliqSpecial .. "]$" ) then ghqgk = "ك" else ghqgk = "گ" end elseif tongue == "back" or tongue == "b" then ae = "ا" ghg = "غ" if match(c, "[" .. consonJsiz .. consonJliqSpecial .. "]$" ) then ghqgk = "ق" else ghqgk = "غ" end end if match(c, "[" .. consonJsiz .. "]$" ) then dt = "ت" else dt = "د" end local temp_v = v2	if temp_v == "" then temp_v = v end if match(temp_v, "[اەېى]$" ) then iuu = "ى" elseif match(temp_v, "[وۇ]$" ) then iuu = "ۇ" elseif match(temp_v, "[ۆۈ]$" ) then iuu = "ۈ" end return {str = str, base = base, tongue = tongue, c = c, v = v, c1=c1, v1 = v1, c2 = c2, v2 = v2, ae=ae, ghqgk = ghqgk, ghg=ghg, dt=dt, iuu=iuu,categories = categories } end

function export.noun(frame) local word = export.get_word(frame) local data = export.createCases(word) export.link(data) return m_case.make_table(data) end

function export.createCases(word) local data = { forms = {}, }	if word.tongue == "" or word.tongue == "central" or word.tongue == nil then -- cat no tongue else local root1 = word.base .. word.v1 .. word.c1 local root2 = word.base .. word.v2 .. word.c2		local iuu if word.c2 == "" then iuu = "" else iuu = word.iuu end --imp export.createCase(data, "imp", word.str, root1, root1 .. "ل" .. word.ae .. "ر", word.ae, word.dt, word.ghqgk, word.ghg) --1st person singular local sl = root2 .. iuu .. "م"; local pl = root1 .. "لىرىم" export.createCase(data, "p1s", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --2nd person singular ordinar sl = root2 .. iuu .. "ڭ"; pl = root1 .. "لىرىڭ" export.createCase(data, "p2so", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --2nd person plural ordinar sl = root2 .. iuu .. "ڭلار"; pl = root1 .. "لىرىڭلار" export.createCase(data, "p2po", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --1st person plural if word.c2 == "" then sl = root1 .. "مىز" else sl = root2 .. "ىمىز" end pl = root1 .. "لىرىمىز" export.createCase(data, "p1p", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --2st person singular refined if word.c2 == "" then sl = root1 .. "ڭىز" else sl = root2 .. "ىڭىز" end pl = root1 .. "لىرىڭىز" export.createCase(data, "p2sr", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --2st person plural refined if word.c2 == "" then sl = root1 .. "ڭىزلار" else sl = root2 .. "ىڭىزلار" end pl = root1 .. "لىرىڭىزلار" export.createCase(data, "p2pr", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --2st person singular & plural respectful sl = root1 .. "لىرى" pl = root1 .. "لىرى" export.createCase(data, "p2spr", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) --3st person if word.c2 == "" then sl = root1 .. "سى" else sl = root2 .. "ى" end pl = root1 .. "لىرى" export.createCase(data, "p3", sl, sl, pl, word.ae, "د", word.ghg, word.ghg) end return data end

function export.createCase(data, short, str, root1, root2, ae, dt, ghqgk, ghg) data.forms[short .. "_nom_s"] = str data.forms[short .. "_nom_p"] = root2 data.forms[short .. "_gen_s"] = root1 .. "نىڭ" ; data.forms[short .. "_gen_p"] = data.forms[short .. "_nom_p"] .. "نىڭ" if not short:find("_") then export.createCase(data, short .. "_gen", data.forms[short .. "_gen_s"] .. "كى", data.forms[short .. "_gen_s"] .. "كى", data.forms[short .. "_gen_p"] .. "كى", "ە", "د","گ", "گ") end data.forms[short .. "_acc_s"] = root1 .. "نى" ; data.forms[short .. "_acc_p"] = data.forms[short .. "_nom_p"] .. "نى" data.forms[short .. "_dat_s"] = root1 .. ghqgk .. ae ; data.forms[short .. "_dat_p"] = data.forms[short .. "_nom_p"] .. ghg .. ae data.forms[short .. "_loc_s"] = root1 .. dt .. ae ; data.forms[short .. "_loc_p"] = data.forms[short .. "_nom_p"] .. "د" .. ae data.forms[short .. "_abl_s"] = root1 .. dt .. "ىن" ; data.forms[short .. "_abl_p"] = data.forms[short .. "_nom_p"] .. "دىن" if short:find("_lqu") then data.forms[short .. "_lqu_s"] = "—" ; data.forms[short .. "_lqu_p"] = "—" ; else data.forms[short .. "_lqu_s"] = root1 .. dt .. "ىكى" ; data.forms[short .. "_lqu_p"] = data.forms[short .. "_nom_p"] .. "دىكى" export.createCase(data, short .. "_lqu", data.forms[short .. "_lqu_s"], data.forms[short .. "_lqu_s"] , data.forms[short .. "_lqu_p"] , "ە", "د","گ" , "گ") end data.forms[short .. "_lim_s"] = root1 .. ghqgk .. "ىچە" ; data.forms[short .. "_lim_p"] = data.forms[short .. "_nom_p"] .. ghg .. "ىچە" data.forms[short .. "_sem_s"] = root1 .. dt .. "ەك" ; data.forms[short .. "_sem_p"] = data.forms[short .. "_nom_p"] .. "دەك" data.forms[short .. "_com_s"] = { root1 .. "چىلىك", root1 .. "چە" } data.forms[short .. "_com_p"] = {data.forms[short .. "_nom_p"] .. "چىلىك", data.forms[short .. "_nom_p"] .. "چە"} data.forms[short .. "_rep_s"] = root1 .. "نىڭكى" ; data.forms[short .. "_rep_p"] = data.forms[short .. "_nom_p"] .. "نىڭكى" if not short:find("_") then export.createCase(data, short .. "_rep", data.forms[short .. "_rep_s"], data.forms[short .. "_rep_s"], data.forms[short .. "_rep_p"], "ە", "د","گ" , "گ") end return forms end

function export.link(data) for key,val in pairs(data.forms) do		if type(val) ~= "table" then val = {val} end local newval = {} for i,form in ipairs(val) do			local newform = form if not mw.ustring.match(key,"nolink") and not mw.ustring.match(form,"—") then newform = m_links.full_link({term = form, lang = lang}) end if mw.ustring.match(form, "—") then newform = "—" end table.insert(newval, newform) end data.forms[key] = table.concat(newval, " or ") end end

return export