মডিউল:pra-decl/noun
এই মডিউলের জন্য মডিউল:pra-decl/noun/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
local export = {}
local m_links = require("Module:links")
local m_translit = require("Module:Brah-translit")
local m_scripts = require("Module:scripts")
local PAGENAME = mw.title.getCurrentTitle().text
local lang = require("Module:languages").getByCode("inc-pra")
local sub = mw.ustring.sub
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local len = mw.ustring.len
local u = mw.ustring.char
local genders = {
["m"] = "পুরুষবাচক", ["f"] = "নারীবাচক", ["n"] = "neuter",
}
export.orjoiner = " <small style=\"color:888\">or</small> " -- Share for testing
local cases = {
"Nominative", "Accusative", "Instrumental", "Dative", "Ablative",
"Genitive", "Locative", "Vocative"
}
local diaeresis = {i = 'ï', u = 'ü'}
function ending(tr)
return sub(tr, -1, -1)
end
function export.joinSuffix(frame, stem, suffixes, etc)
local output = ""
local term
local function to_Brah(tr)
local result = frame:expandTemplate{ title = 'chars', args = { 'inc-pra', tr } }
return result
end
local function to_Deva(tr)
local result = frame:expandTemplate{ title = 'chars', args = { 'sa', tr } }
return result
end
local function to_Knda(tr)
local result = frame:expandTemplate{ title = 'chars', args = { 'inc-pra-Knda', tr } }
return result
end
local function asis(tr) return tr end
local sc = etc and etc.sc or error('Script not provided.')
local converter = etc and etc.converter
if not converter then
converters = {Brah = to_Brah, Deva = to_Deva, Knda = to_Knda}
converter = converters[sc:getCode()] or asis
if etc then etc.converter = converter end
end
for _,suffix in ipairs(suffixes) do
if match(suffix, "^⌫⌫") then --backspace
term = sub(stem, 1, -3) .. 'Ⓙ' .. sub(suffix, 3, -1)
elseif match(suffix, "^⌫") then --backspace
term = sub(stem, 1, -2) .. 'Ⓙ' .. sub(suffix, 2, -1)
else
term = stem .. 'Ⓙ' .. suffix
end
-- May need a diaeresis at the join.
term = gsub(term, 'aⒿⒿ?([iu])', function(x) return 'a' .. diaeresis[x] end)
term = gsub(term, 'Ⓙ', '')
if output ~= "" then
output = output .. export.orjoiner
end
output = output .. m_links.full_link({
lang = lang,
sc = sc,
term = converter(term)})
end
if output == "" then
output = "—"
end
return output
end
function export.select(dialect, word, g, etc)
-- This is a function rather than inline so as to facilitate testing.
-- sc is not yet used, but will be in later forms, and will be script object.
local dn = "Module:pra-decl/noun/" .. dialect
local data = mw.loadData(dn) or error("Could not load data module "..dn)
if not etc then error('Argument etc not provided.') end
if not etc.sc then
error('Argument etc lacks field sc')
-- else error('Argument etc provides script '..etc.sc:getCode())
end
toler_other = false
local word_tr = lang:transliterate(word, etc.sc) or toler_other and word
if not word_tr then
if etc.sc:getCode() == 'None' then
error(word..' is not in a script registered for Prakrit.')
else
error('Unknown transliteration error for '..word)
end
end
-- Special handling for explicit combining diaeresis.
if sub(word_tr, -1, -1) == u(0x0308) then
stem = sub(word_tr, 1, -3) .. 'Ⓙ' .. sub(word_tr, -2, -2)
else
stem = word_tr
end
local the_ending = ending(stem)
return data[the_ending] and data[the_ending][g], stem
end
function export.show(frame, dialect)
local args = frame:getParent().args
local g = args[1]
local word = args[2] or PAGENAME
if PAGENAME == "pmh-decl-noun" or PAGENAME == "psu-decl-noun" or PAGENAME == "pka-decl-noun" or PAGENAME == "inc-mgd-decl-noun" then
g = "m"
word = "𑀧𑀼𑀢𑁆𑀢"
end
local sc = m_scripts.findBestScript(word, lang)
local etc = {sc = sc}
local m_lang = require("Module:languages").getByCode(dialect)
-- 4th argument is to be supplied when it comes to be used.
local selected_data, word_tr = export.select(dialect, word, g, etc)
local output = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background:#FEFEFE; text-align:center; border: 1px solid #CCC;"
|- style="background: #d9ebff;"
! class="vsToggleElement" style="text-align: left;" colspan="3" |]=] .. sub(m_lang:getCanonicalName(), 1, -9) .. [=[ declension of ]=] .. word .. " (" .. genders[g] .. ")"
output = output .. [=[
|- class="vsHide"
! style="background:#eff7ff" |
! style="background:#eff7ff" | singular
! style="background:#eff7ff" | plural
]=]
for i,v in ipairs(cases) do
output = output .. "\n|- class=\"vsHide\"\n! style=\"background-color:#eff7ff;\" | " .. v
output = output .. "\n| " .. export.joinSuffix(frame, word_tr, selected_data[2 * i - 1], etc)
output = output .. "\n| " .. export.joinSuffix(frame, word_tr, selected_data[2 * i], etc)
end
output = output .. "\n|}"
return output
end
function export.pmh(frame)
return export.show(frame, "pmh")
end
function export.psu(frame)
return export.show(frame, "psu")
end
function export.pka(frame)
return export.show(frame, "pka")
end
function export.inc_mgd(frame)
return export.show(frame, "inc-mgd")
end
return export