Module:mr-decl

local export = {} local m_translit = require("Module:mr-translit")

local gsub = mw.ustring.gsub local sub = mw.ustring.sub local match = mw.ustring.match local len = mw.ustring.len

local genders = { ['m'] = 'masculine', ['f'] = 'feminine', ['n'] = 'neuter', }

local function wordify(text) local words, translits = {}, {} for word in mw.text.gsplit(text, ",") do		table.insert(words, mr_format(word)) table.insert(translits, m_translit.tr(word, "mr", "Deva")) end text = table.concat(words, ", ") .. " " .. table.concat(translits, ", ") .. " "	return text end

function mr_format(text) text = (' %s '):format(text) return text end

local function stem(word) return sub(word, 1, -2) end

local function stem_ending(word) return sub(word, -1) end

local function s_obl(word, g)	local ending = stem_ending(word) local stem = stem(word) data = { ["m"] = { ["ी"] = word, ["ा"] = stem .. "्या", ["ू"] = stem .. "वा", ["default"] = word .. "ा"},		["f"] = { ["ी"] = word, ["ा"] = stem .. "े", ["default"] = word .. "ी"},		["f-e"] = { ["default"] = word .. "े"},		["n"] = { ["ी"] = stem .. "्या", ["े"] = stem .. "्या", ["default"] = word .. "ा"}	}	return data[g][ending] or data[g]["default"] end

local function p_dir(word, g)	local ending = stem_ending(word) local stem = stem(word) data = { ["m"] = { ["ा"] = stem .. "े", ["default"] = word }, ["f"] = { ["ी"] = stem .. "्या", ["ा"] = word, ["default"] = word .. "ी"},		["f-e"] = { ["default"] = word .. "ा"},		["n"] = { ["ू"] = stem .. "ं", -- TODO: alternately final "e" ["े"] = stem .. "ी",			["default"] = stem .. "ं" -- TODO: alternately final "e" }	}	-- it's ugly but it works ^_^ if g == "n" and (stem_ending(m_translit.tr(word)) == "a" or ending == "ी") then return word end return data[g][ending] or data[g]["default"] end

function export.show(frame) local args = frame:getParent.args local word = args[1] or mw.title.getCurrentTitle.text local g = args["g"] or args[2] data = [=[ return data end

return export