Module:ta-decl
Appearance
- පහත දැක්වෙන උපදෙස්, Module:ta-decl/documentation හි පිහිටා ඇත. Module:ta-decl/documentation]]. [සංස්කරණය]
- ප්රයෝජනවත් සබැඳි: උප පිටු ලැයිස්තුව • සබැඳි • transclusions • testcases • sandbox
This module serves as the backend for Template:ta-decl.
local export = {}
local m_translit = require("Module:ta-translit")
local m_tamil = require("Module:ta-conj")
local agglutinate = m_tamil.agglutinate
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local match = mw.ustring.match
local len = mw.ustring.len
local long_vowels = {
['ா']= 'ā' , ['ீ']='ī' , ['ூ']='ū' ,
['ே']='ē' , ['ோ']='ō'
}
-- Clone parent’s args while also assigning nil to empty strings.
local function clone_args(frame)
local args = {}
for pname, param in pairs(frame:getParent().args) do
if param == "" then args[pname] = nil
else args[pname] = param
end
end
return args
end
function export.do_generate_forms(args)
local data = {}
local base = args[1] or ""
local PAGENAME = mw.title.getCurrentTitle().text
if base == "" then
base = PAGENAME
end
local type_stem = args.type
data.type_stem = ""
local oblique_sg_base = ""
local plu_base = agglutinate(base, 'கள்', {["do_not_adjust_nasals"] = true}) --default
local special_vocative = nil
categories = ""
oblique_sg_base = base -- default
if (type_stem == "root" or type_stem == "basic" or type_stem == "none") then
-- do nothing
data.type_stem = "root-stem"
elseif (type_stem == "m" or (type_stem == nil and sub(base, -2) == 'ம்')) then
data.type_stem = "m-stem"
oblique_sg_base = sub(base, 1, -3) .. 'த்து'
plu_base = agglutinate(base, 'கள்') --merge nasals
elseif (type_stem == "i" or (type_stem == nil and sub(base, -1) == 'ி')) then
data.type_stem = "i-stem"
elseif (type_stem == "ai" or (type_stem == nil and sub(base, -1) == 'ை')) then
data.type_stem = "ai-stem"
elseif (type_stem == "y" or (type_stem == nil and sub(base, -2) == 'ய்')) then
data.type_stem = "y-stem"
elseif (type_stem == "ā" or (type_stem == nil and sub(base, -1) == 'ா')) then
data.type_stem = "ā-stem"
plu_base = agglutinate(base, 'க்கள்', {})
elseif (type_stem == "ī" or (type_stem == nil and sub(base, -1) == "ீ")) then
data.type_stem = "ī-stem"
plu_base = agglutinate(base, 'க்கள்', {})
elseif (type_stem == "ṟu" or (type_stem == nil and sub(base, -2) == "று" and sub(base, 3) ~= "ற்று")) then
data.type_stem = "ṟu-stem"
oblique_sg_base = sub(base, 1, -3) .. 'ற்று'
elseif (type_stem == "ṭu" or (type_stem == nil and sub(base, -2) == "டு" and sub(base, 3) ~= "ட்டு")) then
data.type_stem = "ṭu-stem"
oblique_sg_base = sub(base, 1, -3) .. 'ட்டு'
elseif (type_stem == "u" or (type_stem == nil and sub(base, -1) == 'ு')) then
data.type_stem = "u-stem"
elseif (type_stem == "l" or (type_stem == nil and sub(base, -2) == "ல்")) then
data.type_stem = "l-stem"
special_vocative = base .. 'லே'
oblique_sg_base = base .. 'லு'
plu_base = sub(base, 1, -3) .. 'ற்கள்'
elseif (type_stem == "ṉ" or (type_stem == nil and sub(base, -2) == "ன்")) then
data.type_stem = "ṉ-stem"
oblique_sg_base = sub(base, 1, -3) .. 'னு'
plu_base = sub(base, 1, -3) .. "ர்கள்"
elseif (type_stem == "ū" or (type_stem == nil and sub(base, -1) == "ூ")) then
data.type_stem = "ū-stem"
oblique_sg_base = base .. "வு"
plu_base = base .. 'க்கள்'
elseif (type_stem == "ḷ" or (type_stem == nil and sub(base, -2) == "ள்")) then
data.type_stem = "ḷ-stem"
oblique_sg_base = sub(base, 1, -3) .. 'ளு'
plu_base = agglutinate(sub(base, 1, -3), 'ட்கள்', {})
else
data.type_stem = "root-stem"
end
if (data.type_stem ~= "root-stem") then
categories = categories .. "[[Category:Tamil " .. data.type_stem .. " nouns]]"
end
if ((args.oblique_sg_base or args[4]) and (args.plu_base or args[2])) then
oblique_sg_base = args.oblique_sg_base or args[4]
plu_base = args.plu_base or args[2]
end
data.nom_sg = args.nom_s or base
data.voc_sg = args.voc_s or args[3] or special_vocative or agglutinate(base, "ஏ", {["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
-- mw.log(oblique_sg_base)
data.acc_sg = args.acc_s or agglutinate(oblique_sg_base, 'ஐ', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.dat_sg = args.dat_s or agglutinate(oblique_sg_base, 'க்கு', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.dat_sg_2 = args.ben_s or agglutinate(oblique_sg_base, 'க்காக', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
if (data.type_stem == "root-stem") then
if not args.dat_s then
data.dat_sg = agglutinate(oblique_sg_base, 'உக்கு', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
end
if not args.ben_s then
data.dat_sg_2 = agglutinate(oblique_sg_base, 'உக்காக', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
end
end
data.gen_sg = args.gen_s or agglutinate(oblique_sg_base, 'உடைய', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.gen_sg_2 = args.gen2_s or agglutinate(oblique_sg_base, 'இன்', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.loc_sg = args.loc_s or agglutinate(oblique_sg_base, 'இல்', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.loc_sg_2 = args.loc2_s or agglutinate(oblique_sg_base, 'இடம்', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.soc_sg = args.soc_s or agglutinate(oblique_sg_base, 'ஓடு', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.soc_sg_2 = args.soc2_s or agglutinate(oblique_sg_base, 'உடன்', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.ins_sg = args.ins_s or agglutinate(oblique_sg_base, 'ஆல்', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.abl_sg = args.abl_s or agglutinate(oblique_sg_base, 'இலிருந்து', {["delete_final_a"] = true, ["delete_final_u"] = true, [ "do_not_duplicate_nasals"] = true, [ "do_not_duplicate_laterals"] = true })
data.nom_pl = args.nom_p or plu_base
data.voc_pl = args.voc_p or agglutinate(plu_base, 'ஏ', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.acc_pl = args.acc_p or agglutinate(plu_base, 'ஐ', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.dat_pl = args.dat_p or agglutinate(plu_base, 'உக்கு', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.dat_pl_2 = args.ben_p or agglutinate(plu_base, 'உக்காக', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.gen_pl = args.gen_p or agglutinate(plu_base, 'உடைய', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.gen_pl_2 = args.gen2_p or agglutinate(plu_base, 'இன்', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.loc_pl = args.loc_p or agglutinate(plu_base, 'இல்', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.loc_pl_2 = args.loc2_p or agglutinate(plu_base, 'இடம்', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.soc_pl = args.soc_p or agglutinate(plu_base, 'ஓடு', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.soc_pl_2 = args.soc2_p or agglutinate(plu_base, 'உடன்', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.ins_pl = args.ins_p or agglutinate(plu_base, 'ஆல்', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
data.abl_pl = args.abl_p or agglutinate(plu_base, 'இலிருந்து', {["delete_final_a"] = true, [ "do_not_duplicate_laterals"] = true })
numbers = "both"
if (args.num == "sg") or args[2] == "-" then
numbers = "singular only"
data.nom_pl = "-"
data.voc_pl = "-"
data.acc_pl = "-"
data.dat_pl = "-"
data.dat_pl_2 = "-"
data.gen_pl = "-"
data.gen_pl_2 = "-"
data.loc_pl = "-"
data.loc_pl_2 = "-"
data.soc_pl = "-"
data.soc_pl_2 = "-"
data.ins_pl = "-"
data.abl_pl = "-"
elseif (args.num == "pl") then
numbers = "plural only"
data.nom_sg = args.nom_s or "-"
data.voc_sg = "-"
data.acc_sg = "-"
data.dat_sg = "-"
data.dat_sg_2 = "-"
data.gen_sg = "-"
data.gen_sg_2 = "-"
data.loc_sg = "-"
data.loc_sg_2 = "-"
data.soc_sg = "-"
data.soc_sg_2 = "-"
data.ins_sg = "-"
data.abl_sg = "-"
end
local data_type = data.type_stem
for k, v in pairs(data) do
if type(v) == "table" then
for k1, v1 in pairs(v) do
if (v1 ~= "-") then
data[k][k1] = '<span class="Taml">[[' .. v1 .. ']]</span> ' .. ' <br/><small style="color: #888">' .. m_translit.tr(v1) .. '</small>'
end
end
else
if (v ~= "-") then
data[k] = '<span class="Taml">[[' .. v .. ']]</span>' .. ' <br/><small style="color: #888">' .. m_translit.tr(v) .. '</small>'
end
end
end
data.base = base .. ' (' .. m_translit.tr(base) .. ')'
data.type_stem = data_type
data.numbers = numbers
data.categories = categories
return data
end
function export.show(frame)
local args = clone_args(frame)
local data = export.do_generate_forms(args)
if (args.notes) then
if (data.type_stem == "") then
data.type_stem = args.notes
else
data.type_stem = data.type_stem .. ", " .. args.notes
end
end
local header = ""
if (data.type_stem ~= "" and data.type_stem ~= "root-stem") then
header = data.type_stem .. " declension of " .. data.base
else
header = "Declension of " .. data.base
end
if (data.numbers ~= "both") then
header = header .. " " .. "<small>(" .. data.numbers .. ")</small>"
end
local res = {'{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background:#FEFEFE; text-align:center; border: 1px solid #CCC;"'}
table.insert(res, '|- style="background: #d9ebff;"')
table.insert(res, '! class="vsToggleElement" style="text-align: left;" colspan="3" | ' .. header)
table.insert(res, '|- class="vsShow"')
table.insert(res, '! style="background:#eff7ff; width: 7em;" | ')
table.insert(res, '! style="background:#eff7ff; width: 10em;" | Singular')
table.insert(res, '! style="background:#eff7ff; width: 10em;" | Plural')
table.insert(res, '|- class="vsShow"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Nominative')
table.insert(res, '| ' .. data.nom_sg)
table.insert(res, '| ' .. data.nom_pl)
table.insert(res, '|- class="vsShow"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Vocative')
table.insert(res, '| ' .. data.voc_sg)
table.insert(res, '| ' .. data.voc_pl)
table.insert(res, '|- class="vsShow"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Accusative')
table.insert(res, '| ' .. data.acc_sg)
table.insert(res, '| ' .. data.acc_pl)
table.insert(res, '|- class="vsShow"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Dative')
table.insert(res, '| ' .. data.dat_sg)
table.insert(res, '| ' .. data.dat_pl)
table.insert(res, '|- class="vsShow"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Genitive')
table.insert(res, '| ' .. data.gen_sg)
table.insert(res, '| ' .. data.gen_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '! style="background:#eff7ff; width: 7em;" | ')
table.insert(res, '! style="background:#eff7ff; width: 10em;" | Singular')
table.insert(res, '! style="background:#eff7ff; width: 10em;" | Plural')
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Nominative')
table.insert(res, '| ' .. data.nom_sg)
table.insert(res, '| ' .. data.nom_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Vocative')
table.insert(res, '| ' .. data.voc_sg)
table.insert(res, '| ' .. data.voc_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Accusative')
table.insert(res, '| ' .. data.acc_sg)
table.insert(res, '| ' .. data.acc_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Dative')
table.insert(res, '| ' .. data.dat_sg)
table.insert(res, '| ' .. data.dat_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Benefactive')
table.insert(res, '| ' .. data.dat_sg_2)
table.insert(res, '| ' .. data.dat_pl_2)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Genitive 1')
table.insert(res, '| ' .. data.gen_sg)
table.insert(res, '| ' .. data.gen_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Genitive 2')
table.insert(res, '| ' .. data.gen_sg_2)
table.insert(res, '| ' .. data.gen_pl_2)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Locative 1')
table.insert(res, '| ' .. data.loc_sg)
table.insert(res, '| ' .. data.loc_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Locative 2')
table.insert(res, '| ' .. data.loc_sg_2)
table.insert(res, '| ' .. data.loc_pl_2)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Sociative 1')
table.insert(res, '| ' .. data.soc_sg)
table.insert(res, '| ' .. data.soc_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Sociative 2')
table.insert(res, '| ' .. data.soc_sg_2)
table.insert(res, '| ' .. data.soc_pl_2)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Instrumental')
table.insert(res, '| ' .. data.ins_sg)
table.insert(res, '| ' .. data.ins_pl)
table.insert(res, '|- class="vsHide"')
table.insert(res, '!style="background:#eff7ff; width: 5em"| Ablative')
table.insert(res, '| ' .. data.abl_sg)
table.insert(res, '| ' .. data.abl_pl)
table.insert(res, '|}')
if (args.no_categories ~= "true" and mw.title.getCurrentTitle().nsText == "") then
table.insert(res, data.categories)
end
return table.concat(res, "\n")
end
return export