Module:ne-conj

local export = {} local m_translit = require("Module:ne-IPA-verb") local m_utilities = require("Module:ne-ut")

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

local comb_list = { ["्अ"] = "‍", ["्आ"] = "ा", ["्इ"] = "ि", ["्ई"] = "ी", ["्ए"] = "े", ["्उ"] = "ु", ["्ऊ"] = "ू", ["्ओ"] = "ो", ["्ऐ"] = "ै", ["्औ"] = "ौ", ["ह्"] = "ह", ["उअ"] = "ऊ", ["उa"] = "ऊ", ["आa"] = "आऊ", ["ाअ"] = "ाऊ", ["ाa"] = "ाऊ", ["्क्"] = "्कि", ["्र्"] = "्रि", ["्ख्"] = "्खि", ["्म्"] = "्मि", ["्ल्"] = "्लि", ["्झ्"] = "्झि", ["्a"] = "", ["ोa"] = "ोऊ", ["a"] = "अ",

}

local function wordify_info(text) text = gsub(text, "्.", comb_list) text = gsub(text, "उ.", comb_list) text = gsub(text, ".a", comb_list) text = gsub(text, "ा.", comb_list) text = gsub(text, "ो.", comb_list) text = gsub(text, "्.्", comb_list) text = gsub(text, ".्", comb_list) text = gsub(text, ".््.", comb_list)

text = m_utilities.link(text) return text end

local function wordify(text) local words, translits = {}, {} text = gsub(text, "्.", comb_list) text = gsub(text, "उ.", comb_list) text = gsub(text, ".a", comb_list) text = gsub(text, "ा.", comb_list) text = gsub(text, "ो.", comb_list) text = gsub(text, "्.्", comb_list) text = gsub(text, ".", comb_list) text = gsub(text, ".्", comb_list) text = gsub(text, ".््.", comb_list) for word in mw.text.gsplit(text, ",") do		table.insert(words, ne_format(word)) table.insert(translits, m_translit.tr(word, "ne", "Deva")) end text = table.concat(words, ", ") .. " [" .. table.concat(translits, ", ") .. " ]"	return text end

function ne_format(text) text = (' '):format(mw.ustring.gsub(text, "[<>ॱ•‌‍]", "")) .. 		('%s '):format(mw.ustring.gsub(text, "[<>•ॱ‌‍]", "")) return text end

local function inj_2s(stem, neg) local inj_2s_rpl = { ["दि"] = { "दे", "दिएस्" }, ["लि"] = { "ले", "लिएस्" }, ["ग"] = { "जा", "गएस्" }, ["आउ"] = { "आ", "आएस्" }, ["बिर्स"] = { "बिर्सी" }, ["बिग्र"] = { "बिग्री" }, ["रह्"] = { "रही" }, ["हेर््"] = { "हेर्" }, ["फेर््"] = { "फेर्" }, ["हो"] = { "भई", "‌भएस्" }, ["दुहु"] = { "दुही", "दुहुएस्" }, ["सह्"] = { "सही", "सहेस्" }, }	words = inj_2s_rpl[stem] or { stem, stem .. "एस्", stem .. "ए" } if neg then return "न‌" .. table.concat(words, ",न‌") else return table.concat(words, ",") end end

local function inj_2p(stem, class, neg) local inj_2p_rpl = { ["दि"] = { "देऊ", "देओ", "दिए" }, ["लि"] = { "लेऊ", "लेओ", "लिए" }, ["ग"] = { "जाऊ", "जाओ", "गए" }, ["आउ"] = { "आऊ", "आओ", "आए" }, ["बिर्स"] = { "बिर्स" }, ["बिग्र"] = { "बिग्र" }, ["रह्"] = { "रह" }, ["हेर््"] = { "हेर‍" }, ["फेर््"] = { "फेर‍" }, ["हो"] = { "भऊ", "भओ", "‌भए" }, ["दुहु"] = { "दुह", "दुहुओ" }, ["सह्"] = { "सह", "सहे" }, } words = inj_2p_rpl[stem] or (class == 1 and { stem .. "अ", stem .. "ए" } or { stem .. "ऊ", stem .. "ओ", stem .. "ए" } ) if neg then if stem == "आउ" then return "न‌" .. table.concat(words, ",न‌") .. "आइज" else return "न‌" .. table.concat(words, ",न‌") end else return table.concat(words, ",") end end

local function imp_2s(stem, neg) local imp_2s_rpl = { ["दि"] = { "दे" }, ["लि"] = { "ले" }, ["ग"] = { "जा" }, ["आउ"] = { "आ" }, ["बिर्स"] = { "बिर्सी" }, ["बिग्र"] = { "बिग्री" }, ["रह्"] = { "रही" }, ["हेर््"] = { "हेर्" }, ["फेर््"] = { "फेर्" }, ["हो"] = { "भई" }, ["दुहु"] = { "दुही" }, ["सह्"] = { "सही" }, }	words = imp_2s_rpl[stem] or { stem } if neg then return "न‌" .. table.concat(words, ",न‌") else return table.concat(words, ",") end end local function imp_2p(stem, class, neg) local imp_2p_rpl = { ["दि"] = { "देऊ", "देओ" }, ["लि"] = { "लेऊ", "लेओ" }, ["ग"] = { "जाऊ", "जाओ" }, ["आउ"] = { "आऊ", "आओ" }, ["बिर्स"] = { "बिर्स" }, ["बिग्र"] = { "बिग्र" }, ["रह्"] = { "रह" }, ["हेर््"] = { "हेर‍" }, ["फेर््"] = { "फेर‍" }, ["हो"] = { "भऊ", "भओ" }, ["दुहु"] = { "दुह", "दुहुओ" }, ["सह्"] = { "सह", "सहे" }, }	words = imp_2p_rpl[stem] or (class == 1 and { stem .. "अ" } or { stem .. "a", stem .. "ओ"} ) if neg then if stem == "आउ" then return "न‌" .. table.concat(words, ",न‌") .. "आइज" else return "न‌" .. table.concat(words, ",न‌") end else return table.concat(words, ",") end end

local function fut_indef(stem_1, stem_2, pos, class, alt_neg) local fut_indef_rpl = { ["1sm"] = { "उँला" }, ["1sf"] = { "उँली" }, ["1p"] = { "औंला" }, ["2sm"] = { "लास्" }, ["2sf"] = { "लिस्" }, ["2pm"] = { "औला", "लाउॱ" }, ["2pf"] = { "औली", "लेउॱ" }, ["3sm"] = { "ला" }, ["3sf"] = { "ली" }, ["3pm"] = { "लान्", "नन्" }, ["3pf"] = { "लिन्", "निन्" }, }	local fut_indef_rpl_c2 = { ["1sm"] = { "उँला" }, ["1sf"] = { "उँली" }, ["1p"] = { "औंला" }, ["2sm"] = { "एलास्" }, ["2sf"] = { "एलिस्" }, ["2pm"] = { "औला", "एलाउॱ" }, ["2pf"] = { "औली", "एलेउॱ" }, ["3sm"] = { "एला" }, ["3sf"] = { "एली" }, ["3pm"] = { "एलान्", "एनन्" }, ["3pf"] = { "एलिन्", "एनिन्" }, }	local fut_indef_rpl_c3_au = { ["1sm"] = { stem_2 .. "उँला" }, ["1sf"] = { stem_2 .. "उँली" }, ["1p"] = { stem_2 .. "औंला" }, ["2sm"] = { stem_1 .. "लास्" }, ["2sf"] = { stem_1 .. "लिस्" }, ["2pm"] = { stem_2 .. "औला", stem_1 .. "लाउॱ" }, ["2pf"] = { stem_2 .. "औली", stem_1 .. "लेउॱ" }, ["3sm"] = { stem_1 .. "ला" }, ["3sf"] = { stem_1 .. "ली" }, ["3pm"] = { stem_1 .. "लान्", stem_1 .. "नन्" }, ["3pf"] = { stem_1 .. "लिन्", stem_1 .. "निन्" }, }	na = "" if alt_neg then na = "न‌" end if class == 1 or match(stem_1, "ा$") then return na .. stem_1 .. table.concat(fut_indef_rpl[pos], "," .. na .. stem_1) elseif class == 2 then if stem_1 == "दि" or stem_1 == "लि" then if not match(pos, "^1") then stem_1 = gsub(stem_1, "..", { ["दि"] = "दे", ["लि"] = "ले" } ) end return na .. stem_1 .. table.concat(fut_indef_rpl[pos], "," .. na .. stem_1) else return na .. stem_1 .. table.concat(fut_indef_rpl_c2[pos], "," .. na .. stem_1) end elseif count_c(stem_1) == 1 and match(stem_1, "ु$") then return na .. stem_2 .. table.concat(fut_indef_rpl[pos], "," .. na .. stem_2) else return na .. table.concat(fut_indef_rpl_c3_au[pos], "," .. na) end end

local function fut_indef_neg(stem_1, stem_2, pos, class) local fut_indef_neg_rpl = { ["1s"] = "ओइॱनँ", ["1p"] = "ओइॱनौं", ["2s"] = "ओइॱनस्", ["2p"] = "ओइॱनौ", ["3s"] = "ओइॱन‍", ["3p"] = "ओइॱनन्", }	if class == 1 or match(stem_1, "ा$") or class == 2 then return stem_1 .. fut_indef_neg_rpl[pos] else return stem_2 .. fut_indef_neg_rpl[pos] end end

function count_c(text) return len(gsub(text, "[^कखगघङचछजझञटठडढतथदधपफबभशषसयरलहवणनम]", "")) end

function export.show(frame) local args = frame:getParent.args local word = args[1] or mw.title.getCurrentTitle.text local irreg = args["irreg"] or false local stem_2 = args["stem_2"] or false local i_stem = args["i"] or false local a_stem = args["a"] or false local passive = args["p"] or false local causative = args["c"] or false local class = 1 local stem_1, stem_1_n = "", ""

if match(word, "‍") then error("It contains the invisible character (zero-width joiner: 0x200D).") end if not match(word, "नु$") then error("Please ensure inputted word is a verb in its nu-infinitive form.") end denu = sub(word, 1, -3) denu_translit = m_translit.tr(denu, "ne", "Deva") -- aau-: (1) aau-, (2) aa-, (3) aauṁ- if match(denu_translit, "([āäi])u$") then class = 3 stem_1 = denu stem_2 = sub(denu, 1, -2) stem_1_n = denu .. "ँ"	elseif match(denu_translit, "[^aäʌāiīuūeo]u$") then class = 3

-- dhu-: (1) dhu-, (2) dho-, (3) dhun- if count_c(denu) == 1 then stem_1 = denu stem_2 = sub(denu, 1, -2) .. "ो"			stem_1_n = denu .. "न्" -- duhu-: (1) duhu-, (2) duh-, (3) duh- else stem_1 = denu stem_2 = sub(denu, 1, -2) .. "ो"			stem_1_n = denu end -- birsa-: (1) birsa-, (2) birs-, (3) birsan- elseif match(denu_translit, "[^aäʌāiīuūeo]a$") then class = 3 stem_1 = denu stem_2 = denu .. "्"		stem_1_n = denu .. "न्" -- jaa-: (1) jaa-, (2) ga-, (3) jaan- elseif denu_translit == "jā" or irreg then class = 3 stem_1 = denu stem_2 = stem_2 or gsub(denu, "जा", "ग") stem_1_n = denu .. "न्" -- khaa-: (1) khaa-, (2) khaa-, (3) khaan- elseif match(denu_translit, "[aäʌāiīuūeo]$") then class = 2 stem_1 = denu stem_2 = stem_1 stem_1_n = denu .. "न्" -- gar-: (1) gar-, (2) gar-, (3) gar- else stem_1 = denu stem_2 = stem_1 stem_1_n = stem_1 end stem_1_n_2 = gsub(stem_1_n, "न्$", "ँ") info = [=[

Conjugation of ]=] .. m_utilities.link(word) .. [=[

form = info .. [=[

return form end

return export