Module:User:Oyunqi/ug-decl-noun1

-- 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 = m_com.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 vv = args[1] or nil local cc = args[2] or nil if tongue == nil then tongue = m_com.checkTongue(str) end local v1 = v; v2 = v; c1 = c; c2 = c   if vv then if c == "" then -- open if (v == "ا" or v == "ە") then v1 = vv; else v2 = vv; c2 = "ي" end else --close if (v == "ا" or v == "ە") then v2 = vv	   	elseif vv == "-" then v2 = "" end end else if c == "" then -- open c2 = "ي" end 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(v2, "[اەېى]$" ) then iuu = "ى" elseif match(v2, "[وۇ]$" ) then iuu = "ۇ" elseif match(v2, "[ۆۈ]$" ) 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 sl = word.base .. word.v2 .. word.c2 .. iuu .. "م" local pl = word.base .. word.v1 .. word.c1 .. "لىرىم" forms["case1s"] = export.createGen(sl, pl, word.ae, word.dt, word.ghqgk, word.ghg) sl = word.base .. word.v2 .. word.c2 .. iuu .. "ڭ" pl = word.base .. word.v1 .. word.c1 .. "لىرىڭ" forms["case2s"] = export.createGen(sl, pl, word.ae, word.dt, word.ghqgk, word.ghg) end return forms end

return export