Module:User:Oyunqi/ug-decl-noun

-- Table of exported functions. local export = {} m_com = require("Module:User:Oyunqi/ug-common1") local match = mw.ustring.match

function export.show(frame) local word = export.check(frame) local nouns = export.createCases(word) local result = {} for k, forms in pairs(nouns) do		table.insert(result, frame:expandTemplate({title = "Template:ug-cases-table", args = forms})) end return table.concat(result) end

function export.check(frame) local args if frame.args["test"] then args = frame.args else args = frame:getParent.args end local str = args["head"] or "" local tongue = args["tongue"] or nil local change = args["change"] or 1 local PAGENAME = mw.title.getCurrentTitle.text if str == "" then str = PAGENAME; end local base, v, c, cnt = m_com.getLast(str) local v1 = args[1] or args["v1"] or nil local c1 = args[2] or args["c1"] or nil local v2 = args["v2"] or nil local c2 = args["c2"] or nil if tongue == nil then tongue = m_com.checkTongue(str) end if change and change ~="no" then if v1 == nil then if cnt > 1 and c=="" and (v == "ا" or v == "ە") then v1 = "ى" else v1 = v end end if c1 == nil then c1 = c		end if v2 == nil then if cnt == 1 and c ~= "" and (v == "ا" or v == "ە") then v2 = "ې" else v2 = v end if cnt > 1 and c ~= "" and (v == "ا" or v == "ە") then v2 = "ى" else v2 = v end end if c2 == nil then if v1 == v and c == "" then c2 = "ي" else c2 = c	   	end end else v1 = v; c1 = c; v2 = v; c2 = c	end local ae = "" local ghqgk; local ghg local consonJsiz = "پتچخسشفقكھ" local consonJliqSpecial = "غگبد" local dt	local iuu 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 if match(v, "[اەېى]$" ) then iuu = "ى" elseif match(v, "[وۇ]$" ) then iuu = "ۇ" elseif match(v, "[ۆۈ]$" ) then iuu = "ۈ" end local word = {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 } return word end

function export.createCase(str, root1, root2, ae, dt, ghqgk, ghg) local forms = {} forms[1] = str ; forms[2]= root2 .. "ل" .. ae .. "ر" forms[3]= root2 .. "نىڭ" ; forms[4]= forms[2] .. "نىڭ" forms[5]= root2 .. "نى" ; forms[6]= forms[2] .. "نى" forms[7]= root2 .. ghqgk .. ae ; forms[8]= forms[2] .. ghg .. ae forms[9]= root2 .. dt .. ae ; forms[10]= forms[2] .. "د" .. ae forms[11]= root2 .. dt .. "ىن" ; forms[12]= forms[2] .. "دىن" forms[13]= root2 .. dt .. "ىكى" ; forms[14]= forms[2] .. "دىكى" forms[15]= root2 .. ghqgk .. "ىچە" ; forms[16]= forms[2] .. ghg .. "ىچە" forms[17]= root2 .. dt .. "ەك" ; forms[18]= forms[2] .. "دەك" forms[19]= root2 .. "چىلىك" ; forms[20]= forms[2] .. "چىلىك" forms[21]= root2 .. "چە" ; forms[22]= forms[2] .. "چە" return forms end

function export.createGen(root1, root2, ae, dt, ghqgk, ghg) local forms = {} forms[1] = root1 ; forms[2]= root2 forms[3]= root1 .. "نىڭ" ; forms[4]= root2 .. "نىڭ" forms[5]= root1 .. "نى" ; forms[6]= root2 .. "نى" forms[7]= root1 .. ghqgk .. ae ; forms[8]= root2 .. ghg .. ae forms[9]= root1 .. dt .. ae ; forms[10]= root2 .. "د" .. ae forms[11]= root1 .. dt .. "ىن" ; forms[12]= root2 .. "دىن" forms[13]= root1 .. dt .. "ىكى" ; forms[14]= root2 .. "دىكى" forms[15]= root1 .. ghqgk .. "ىچە" ; forms[16]= root2 .. ghg .. "ىچە" forms[17]= root1 .. dt .. "ەك" ; forms[18]= root2 .. "دەك" forms[19]= root1 .. "چىلىك" ; forms[20]= root2 .. "چىلىك" forms[21]= root1 .. "چە" ; forms[22]= root2 .. "چە" return forms end

function export.createLqu(root1, root2, ae, dt, ghqgk, ghg) local forms = {} forms[1] = root1 ; forms[2]= root2 forms[3]= root1 .. "نىڭ" ; forms[4]= root2 .. "نىڭ" forms[5]= root1 .. "نى" ; forms[6]= root2 .. "نى" forms[7]= root1 .. ghqgk .. ae ; forms[8]= root2 .. ghg .. ae forms[9]= root1 .. dt .. ae ; forms[10]= root2 .. "د" .. ae forms[11]= root1 .. dt .. "ىن" ; forms[12]= root2 .. "دىن" forms[13]= "-" ; forms[14]= "-" forms[15]= root1 .. ghqgk .. "ىچە" ; forms[16]= root2 .. ghg .. "ىچە" forms[17]= root1 .. dt .. "ەك" ; forms[18]= root2 .. "دەك" forms[19]= root1 .. "چىلىك" ; forms[20]= root2 .. "چىلىك" forms[21]= root1 .. "چە" ; forms[22]= root2 .. "چە" return forms end

function export.createCases(word) local forms = {} if word.tongue == "" or word.tongue == "central" or word.tongue == nil then -- cat no tongue else --local forms = {} local root1 = word.base .. word.v1 .. word.c1 local root2 = word.base .. word.v1 .. word.c1		forms["case0"] = export.createCase(word.str, root1, root2, word.ae, word.dt, word.ghqgk, word.ghg) --table.insert(result, forms.case) if forms["case0"][3] and forms["case0"][4] then --temp1 = forms[3] .. "كى" --temp2 = forms[4] .. "كى" forms["case0.gen"] = export.createGen(forms["case0"][3] .. "كى", forms["case0"][4] .. "كى", "ە", "د","گ", "گ") --table.insert(result, temps) end if forms["case0"][13] and forms["case0"][14] then forms["case0.lqu"] = export.createLqu(forms["case0"][13], forms["case0"][14] ,"ە", "د","گ" , "گ") end local iuu if word.c2 == "" then iuu = "" else iuu = word.iuu end local c1sroot1 = word.base .. word.v2 .. word.c2 .. iuu .. "م" local c1sroot2 = word.base .. word.v1 .. word.c2 .. "لىرىم" forms["case1s"] = export.createGen(c1sroot1, c1sroot2, word.ae, word.dt, word.ghqgk, word.ghg) end return forms end

function create(frame, word) local forms = {} if word.tongue == "" or word.tongue == "central" or word.tongue == nil then -- cat no tongue return "" else local result = {} local root1 = word.base .. word.v .. word.c local root2 = word.base .. word.v2 .. word.c2		forms["str"] = root1 forms["nom.s"] = root1 ; forms["nom.p"]= root2 .. "ل" .. word.ae .. "ر" forms["gen.s"]= root2 .. "نىڭ" ; forms["gen.p"]= forms["nom.p"] .. "نىڭ" forms["acc.s"]= root2 .. "نى" ; forms["acc.p"]= forms["nom.p"] .. "نى" forms["dat.s"]= root2 .. word.ghqgk .. word.ae ; forms["dat.p"]= forms["nom.p"] .. word.ghg .. word.ae forms["loc.s"]= root2 .. word.dt .. word.ae ; forms["loc.p"]= forms["nom.p"] .. "د" .. word.ae forms["abl.s"]= root2 .. word.dt .. "ىن" ; forms["abl.p"]= forms["nom.p"] .. "دىن" forms["lqu.s"]= root2 .. word.dt .. "ىكى" ; forms["lqu.p"]= forms["nom.p"] .. "دىكى" forms["lim.s"]= root2 .. word.ghqgk .. "ىچە" ; forms["lim.p"]= forms["nom.p"] .. word.ghg .. "ىچە" forms["sem.s"]= root2 .. word.dt .. "ەك" ; forms["sem.p"]= forms["nom.p"] .. "دەك" forms["com.s"]= root2 .. "چىلىك" ; forms["com.p"]= forms["nom.p"] .. "چىلىك" table.insert(result, frame:expandTemplate({title = "Template:ug-cases-table", args = forms})) if forms["gen.s"] then root1 = forms["gen.s"] .. "كى" root2 = forms["gen.p"] .. "كى" forms["str"] = root1 forms["nom.s"] = root1 ; forms["nom.p"]= root2 forms["gen.s"]= root1 .. "نىڭ" ; forms["gen.p"]= root2 .. "نىڭ" forms["acc.s"]= root1 .. "نى" ; forms["acc.p"]= root2 .. "نى" forms["dat.s"]= root1 .. "گە" ; forms["dat.p"]= root2 .. "گە" forms["loc.s"]= root1 .. "دە" ; forms["loc.p"]= root2 .. "دە" forms["abl.s"]= root1 .. "دىن" ; forms["abl.p"]= root2 .. "دىن" forms["lqu.s"]= root1 .. "دىكى" ; forms["lqu.p"]= root2 .. "دىكى" forms["lim.s"]= root1 .. "گىچە" ; forms["lim.p"]= root2 .. "گىچە" forms["sem.s"]= root1 .. "دەك" ; forms["sem.p"]= root2 .. "دەك" forms["com.s"]= root1 .. "چىلىك" ; forms["com.p"]= root2 .. "چىلىك" table.insert(result, frame:expandTemplate({title = "Template:ug-cases-table", args = forms})) end return table.concat(result) end end

return export