Module:mr-decl

Hello, you have come here looking for the meaning of the word Module:mr-decl. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:mr-decl, but we will also tell you about its etymology, its characteristics and you will know how to say Module:mr-decl in singular and plural. Everything you need to know about the word Module:mr-decl you have here. The definition of the word Module:mr-decl will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:mr-decl, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


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 = {
	 = 'masculine',  = 'feminine',  = '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, ", ") .. "<br><small style=\"color:#888\">" ..
		table.concat(translits, ", ") .. "</small>"
	return text
end

function mr_format(text)
	text = ('<span lang="mr" class="Deva">]</span>'):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 = {
		 = {  = word,  = stem .. "्या",  = stem .. "वा",  = word .. "ा"},
		 = {  = word,  = stem .. "े",  = word .. "ी"},
		 = {  = word .. "े"},
		 = {  = stem .. "्या",  = stem .. "्या",  = word .. "ा"}
	}
	
	return data or data
end

local function p_dir(word, g)
	local ending = stem_ending(word)
	local stem = stem(word)
	
	data = {
		 = {  = stem .. "े",  = word },
		 = {  = stem .. "्या",  = word,  = word .. "ी"},
		 = {  = word .. "ा"},
		 = {  = stem .. "ं", -- TODO: alternately final "e"
			 = stem .. "ी",
			 = 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 or data
end

function export.show(frame)
	local args = frame:getParent().args
	local word = args or mw.title.getCurrentTitle().text
	local g = args or args
	
	data = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background:#FEFEFE; text-align:center; border: 1px solid #CCC; min-width:30%"
|- style="background: #d9ebff;"
! class="vsToggleElement" style="text-align: left;" colspan="4" | Declension of ]=] .. mr_format(word) .. " " .. genders
	
	data = data .. [=[

|- class="vsShow"
| style="background:#eff7ff" | ''dir. sg.''
| ]=] .. wordify(word) .. [=[

|- class="vsShow"
| style="background:#eff7ff" | ''dir. pl.''
| ]=] .. wordify(p_dir(word, g))

	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | nominative
| ]=] .. wordify(word) .. "||" .. wordify(p_dir(word, g))
	
	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | oblique
| ]=] .. wordify(s_obl(word, g)) .. "||" .. wordify(s_obl(word, g) .. "ं")

	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | dative
| ]=] .. wordify(s_obl(word, g) .. "ला") .. "||" .. wordify(s_obl(word, g) .. "ंना")

	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | ergative
| ]=] .. wordify(s_obl(word, g) .. "ने") .. "||" .. wordify(s_obl(word, g) .. "ंनी")

	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | instrumental
| ]=] .. wordify(s_obl(word, g) .. "शी") .. "||" .. wordify(s_obl(word, g) .. "ंशी")

	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | locative
| ]=] .. wordify(s_obl(word, g) .. "त") .. "||" .. wordify(s_obl(word, g) .. "ंत")

	data = data .. [=[

|- class="vsHide"
! style="background:#eff7ff" | vocative
| ]=] .. wordify(s_obl(word, g)) .. "||" .. wordify(s_obl(word, g) .. "ंनो")
	
	data = data .. [=[

|}]=]
	
	return data
end

return export