local export = {}
function export.main(frame)
local lenition = {
= "ج",
= "غ",
= "ب",
= "د",
= "c",
= "ğ",
= "b",
= "d"
}
local highVowel = {
= "ı", = "ı", = "ı",
= "i", = "i", = "i",
= "u", = "u", = "u",
= "ü", = "ü"
}
local lowVowel = {
= "a", = "a", = "a", = "a", = "a", = "a",
= "e", = "e", = "e", = "e", = "e"
}
local args = require("Module:parameters").process(frame:getParent().args, {
= {},
= {},
= {},
= {},
= {},
= {},
= {},
= {}
})
local V = "aeıioöuüâîû"
local C = "’‘bcçdfgğhjklmnñprsştvyz"
local function analyze(word, tr)
local endsInVowel = mw.ustring.find(V, mw.ustring.sub(tr, -1))
local stem = word
local stemTr = tr
if mw.ustring.find(tr, "%(") then
stemTr = mw.ustring.gsub(tr, "%(.*%)", "")
tr = mw.ustring.gsub(tr, "", "")
end
if mw.ustring.find(tr, "%-$") then
stem = mw.ustring.sub(word, 1, -2) .. (lenition or mw.ustring.sub(word, -1))
tr = mw.ustring.sub(tr, 1, -2)
stemTr = mw.ustring.sub(tr, 1, -2) .. lenition
end
return stem, tr, stemTr, endsInVowel
end
local function poss(word, stem, tr, stemTr, endsInVowel, vowel, isPl)
local poss = {}
local nj = ""
if endsInVowel and mw.ustring.find("ه", mw.ustring.sub(stem, -1)) then
nj = ""
end
local fsAr = stem .. nj .. "م"
local ssAr = stem .. nj .. "ك"
local tsAr = stem .. nj .. (endsInVowel and "س" or "")
local fpAr = stem .. nj .. "مز"
local spAr = stem .. nj .. "كز"
local tpAr = word .. (isPl and "" or (nj .. "لر"))
poss = {fsAr, ssAr, tsAr, fpAr, spAr, tpAr}
local fsLt = stemTr .. (endsInVowel and "" or highVowel) .. "m"
local ssLt = stemTr .. (endsInVowel and "" or highVowel) .. "ñ"
local tsLt = stemTr .. (endsInVowel and "s" or "") .. highVowel
local fpLt = stemTr .. (endsInVowel and "" or highVowel) .. "m" .. highVowel .. "z"
local spLt = stemTr .. (endsInVowel and "" or highVowel) .. "ñ" .. highVowel .. "z"
local tpLt = tr .. (isPl and highVowel or ("l" .. lowVowel .. "r" .. highVowel]))
poss = {fsLt, ssLt, tsLt, fpLt, spLt, tpLt}
return poss
end
local function decl(word, stem, tr, stemTr, endsInVowel, vowel, isPoss, isPl)
local decl = {}
local nj, yNj = "", ""
if endsInVowel and not isPoss then
if mw.ustring.find("ه", mw.ustring.sub(stem, -1)) then
nj = ""
yNj = nj
elseif mw.ustring.find("ی", mw.ustring.sub(stem, -1)) then
yNj = ""
end
end
local epen = "ن"
local dEpen = epen
if isPoss and mw.ustring.find("دذرزژو", mw.ustring.sub(stem, -1)) then
epen = "ین"
dEpen = "ین"
if isPl then
dEpen = "ن"
end
end
local nomAr = word .. ((endsInVowel and isPoss) and "ی" or "")
local accAr = stem .. yNj .. (endsInVowel and (isPoss and epen or "ی") or "") .. "ی"
local datAr = stem .. yNj .. (endsInVowel and (isPoss and epen or "ی") or "") .. "ه"
local locAr = word .. nj .. (endsInVowel and (isPoss and dEpen or "") or "") .. "ده"
local ablAr = word .. nj .. (endsInVowel and (isPoss and dEpen or "") or "") .. "دن"
local genAr = stem .. nj .. (endsInVowel and epen or "") .. "ك"
decl = {nomAr, accAr, datAr, locAr, ablAr, genAr}
local nomLt = tr
local accLt = stemTr .. (endsInVowel and (isPoss and "n" or "y") or "") .. highVowel
local datLt = stemTr .. (endsInVowel and (isPoss and "n" or "y") or "") .. lowVowel
local locLt = tr .. ((endsInVowel and isPoss) and "n" or "") .. "d" .. lowVowel
local ablLt = tr .. ((endsInVowel and isPoss) and "n" or "") .. "d" .. lowVowel .. "n"
local genLt = stemTr .. (endsInVowel and "n" or "") .. highVowel .. "ñ"
decl = {nomLt, accLt, datLt, locLt, ablLt, genLt}
return decl
end
local function decl_poss(poss, isPl)
for i in ipairs(poss.Ar) do
local possStem, possTr, possStemTr, possEndsInVowel = analyze(poss.Ar, poss.Lt)
local possVowel = mw.ustring.match(possTr, "()%)?*%-?$")
local possDecl = decl(poss.Ar, possStem, possTr, possStemTr, possEndsInVowel, possVowel, true, (isPl or i == 6))
poss.Ar = possDecl.Ar
poss.Lt = possDecl.Lt
end
return poss
end
local items = { = args.poss}
local sgWord = args.word or mw.title.getCurrentTitle().text
local sgTr = args.tr
local sgVowel = args.v or mw.ustring.match(sgTr, "()%)?*%-?$")
local sgStem, sgTr, sgStemTr, sgEndsInVowel = analyze(sgWord, sgTr)
local sgDecl = decl(sgWord, sgStem, sgTr, sgStemTr, sgEndsInVowel, sgVowel, false)
local plWord, plStem, plTr, plStemTr, plVowel, plEndsInVowel
local plDecl = {
= {"–", "–", "–", "–", "–", "–"},
= {"", "", "", "", "", ""}
}
if args.n ~= "s" then
plWord = args.pl or sgWord .. ((sgEndsInVowel and mw.ustring.find("ه", mw.ustring.sub(sgStem, -1))) and "" or "") .. "لر"
plTr = args.pltr or sgTr .. "l" .. lowVowel .. "r"
plVowel = args.plv or mw.ustring.match(plTr, "()%)?*%-?$")
plStem, plTr, plStemTr, plEndsInVowel = analyze(plWord, plTr)
plDecl = decl(plWord, plStem, plTr, plStemTr, plEndsInVowel, plVowel, false)
end
for i = 1, 6 do
table.insert(items, sgDecl.Ar)
table.insert(items, sgDecl.Lt)
table.insert(items, plDecl.Ar)
table.insert(items, plDecl.Lt)
end
if args.poss ~= "no" then
local sgPoss = decl_poss(poss(sgWord, sgStem, sgTr, sgStemTr, sgEndsInVowel, sgVowel, false), false)
local plPoss = {
= {{"–", "–", "–", "–", "–", "–"}, {"–", "–", "–", "–", "–", "–"}, {"–", "–", "–", "–", "–", "–"}, {"–", "–", "–", "–", "–", "–"}, {"–", "–", "–", "–", "–", "–"}, {"–", "–", "–", "–", "–", "–"}},
= {{"", "", "", "", "", ""}, {"", "", "", "", "", ""}, {"", "", "", "", "", ""}, {"", "", "", "", "", ""}, {"", "", "", "", "", ""}, {"", "", "", "", "", ""}}
}
if args.n ~= "s" then
plPoss = decl_poss(poss(plWord, plStem, plTr, plStemTr, plEndsInVowel, plVowel, not args.pl), not args.pl)
end
for i = 1, 6 do
for j = 1, 6 do
table.insert(items, sgPoss.Ar)
table.insert(items, sgPoss.Lt)
table.insert(items, plPoss.Ar)
table.insert(items, plPoss.Lt)
end
end
end
return frame:expandTemplate{title = "Template:ota-decl-table", args = items}
end
return export