ماڈیوٗل:ks-deva-decl-noun-m
"یَمہٕ ماڈیوٗلُک دَستاویز ییٚہِ ماڈیوٗل:ks-deva-decl-noun-m/دَستاویز جاے بَناونہٕ"
local p = {}
local vowels = {'ि', 'ी', 'ॖ', 'ॗ', 'ु', 'ू', 'ॆ', 'े', 'ऺ', 'ऻ', 'ॊ', 'ो', 'ॏ', 'ा', 'ै', 'ौ'}
local aspirated = {['ख'] = 'क', ['घ'] = 'ग', ['छ'] = 'च', ['झ'] = 'ज', ['ठ'] = 'ट', ['ढ'] = 'ड',
['थ'] = 'त', ['ध'] = 'द', ['फ'] = 'प', ['भ'] = 'ब', ['छ'] = '़', ['ख़'] = 'क़', ['ढ़'] = 'ड़',}
local subbed_vows = {["ु"] = "ॖ",
["ू"] = "ॗ",
["ॊ"] = "ऺ",
["ो"] = "ऻ",
}
function p.table_len(tab)
length = 0
for _ in ipairs(tab) do
length = length + 1
end
return length
end
function p.contains_val(lst, w)
for _, t in pairs(lst) do
if string.match(w, t) then
return true
end
end
return false
end
function p.contains_key(lst, w)
for t, _ in pairs(lst) do
if string.match(w, t) then
return true
end
end
return false
end
function p.last_vow(word)
local length = string.len(word)
local v = {}
for i = 1, length, 3 do
local let = word:sub(-i-2, -i)
if p.contains_val(vowels, let) then
return {length-i, let}
end
end
end
function p.get_stem(word)
local length = string.len(word)
local last = word:sub(-3, -1)
if p.contains_key(aspirated, last) then
return word:sub(1, length-3) .. aspirated[last]
elseif word:sub(-3, -1) == 'ॖ' then
return(word:sub(1, length-3))
end
return word
end
function p.index(lst, e)
for i, v in ipairs(lst) do
if v == e then
return i
end
end
return nil
end
function p.nom_s(word)
return word
end
function p.nom_pl(word, pattern)
local last = word:sub(-3, -1)
local length = string.len(word)
if last == "ॖ" then
return word
else
local l_v = p.last_vow(word)
if p.contains_key(subbed_vows, l_v[2]) then
local out = ""
for i = 1, length, 3 do
local chr = word:sub(i, i+2)
if i == l_v[1]-1 then
out = out .. subbed_vows[l_v[2]]
else
out = out .. chr
end
end
return out .. "्य"
elseif l_v[2] == "ा" then
return word
else
return word .. '्य'
end
end
end
function p.dat_s(word)
local l_v = p.last_vow(word)
local length = string.len(word)
if l_v[2] == "ु" then
out = ""
for i = 1, length, 3 do
local chr = word:sub(i, i+2)
if i ~= l_v[1]-1 then
out = out .. chr
end
end
out = out .. "िस"
return out
else
return p.get_stem(word) .. "स"
end
end
function p.dat_pl(word)
local l_v = p.last_vow(word)
local length = string.len(word)
if l_v[2] == "ु" then
out = ""
for i = 1, length, 3 do
local chr = word:sub(i, i+2)
if i ~= l_v[1]-1 then
out = out .. chr
end
end
out = out .. "्यन"
return out
else
return p.get_stem(word) .. "न"
end
end
function p.erg_s(word)
local l_v = p.last_vow(word)
local length = string.len(word)
if l_v[2] == "ु" then
out = ""
for i = 1, length, 3 do
local chr = word:sub(i, i+2)
if i ~= l_v[1] - 1 then
out = out .. chr
end
end
out = out .. "ॖ"
return out
else
return p.get_stem(word) .. "न"
end
end
function p.erg_pl(word)
local l_v = p.last_vow(word)
local length = string.len(word)
if l_v[2] == "ु" then
out = ""
for i = 1, length, 3 do
local chr = word:sub(i, i+2)
if i ~= l_v[1]-1 then
out = out .. chr
end
end
out = out .. "्यव"
return out
else
return p.get_stem(word) .. "व"
end
end
function p.abl_s(word)
local l_v = p.last_vow(word)
local length = string.len(word)
if l_v[2] == "ु" then
out = ""
for i = 1, length, 3 do
local chr = word:sub(i, i+2)
if i ~= l_v[1]-1 then
out = out .. chr
end
end
return out .. "ॖ"
else
local stem = p.get_stem(word)
return stem .. "ॖ"
end
end
function p.abl_pl(word)
return p.erg_pl(word)
end
return p