Module:sju-common

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local langdata = {
	consonant = {
		"^(.-)([^aáeēiïouūüǖyåäöAÁEĒIÏOUŪÜǕYÅÄÖ" .. mw.ustring.char(0x0304) .. "{}-]*)$",
	},
	vowel = {
		"^(.-)(eä)$",
		"^(.-)(i[eä])$",
		"^(.-)(u[aeoö])$",
		"^(.-)(yö)$",
		"^(.-)(å̄)$",
		"^(.-)([aáeēiïuūüǖyåä]?)$",
	},
	scons = {
		[1] = {
		},
		[2] = {
			{"^bm$", "m", "bˈm"},
			{"^dn(j?)$", "n%1", "dˈn%1"},
			{"^gŋ$", "ŋ", "gˈŋ"},
			{"^([đjlmnŋrsv])%1$", "%1", "%1ˈ%1"},
			{"^hp$", "b", "hpp"},
			{"^ht$", "d", "htt"},
			{"^ht([js])$", "t%1", "htt%1"},
			{"^hk$", "g", "hkk"},
			{"^([ns])%1j$", "%1j", "%1ˈ%1j"},
		},
		[3] = {
			{"^bˈb$", "bb"},
			{"^gˈg$", "gg"},
			{"^dˈt([js])$", "dt%1"},
			
			{"^(l)%1([j])$", "%1%2"},
			{"^(s)%1(j?[kmnŋptv])$", "%1%2"},
			
			{"^(b)([dđjlr])%2$", "%1%2"},
			{"^(đ)([gv])%2$", "%1%2"},
			{"^(g)([l])%2$", "%1%2"},
			{"^(j)([bdđgklprstv])%2$", "%1%2"},
			{"^(js)s(j)$", "%1%2"},
			{"^(jt)t([js])$", "%1%2"},
			{"^(k)([s])%2$", "%1%2"},
			{"^(ks)s(j)$", "%1%2"},
			{"^(kt)t([js])$", "%1%2"},
			{"^(l)([dfksv])%2$", "%1%2"},
			{"^(ls)s(j)$", "%1%2"},
			{"^(lt)t([js])$", "%1%2"},
			{"^(m)([bgkps])%2$", "%1%2"},
			{"^(mt)t([js])$", "%1%2"},
			{"^(nj?)([dst])%2$", "%1%2"},
			{"^(nj?t)t([js])$", "%1%2"},
			{"^(ŋ)([gks])%2$", "%1%2"},
			{"^(p)([kst])%2$", "%1%2"},
			{"^(ps)s(j)$", "%1%2"},
			{"^(pt)t([js])$", "%1%2"},
			{"^(r)([dfjstv])%2$", "%1%2"},
			{"^(rs)s(j)$", "%1%2"},
			{"^(rt)t([js])$", "%1%2"},
			{"^(s)([m])%2$", "%1%2"},
			{"^(ŧ)([km])%2$", "%1%2"},
			{"^(v)([đjklrs])%2$", "%1%2"},
			{"^(vs)s(j)$", "%1%2"},
			{"^(vt)t([js])$", "%1%2"},
			
			{"^([j])d(n)$", "%1%2"},
		},
	},
	vowel_variants = {
		normal = {               ["ie"] = {"ie", "R"},                    },
		v      = {["a"] = {"u"}, ["ie"] = {"ie", "R"},                    },
		j      = {["a"] = {"i"}, ["ie"] = {"i", "I"} ,                    },
		je     = {["a"] = {"i"}, ["ie"] = {"á", "L"} , ["uo"] = {"i", "U"}},
	},
	postprocess = function(form, vowel_effect)
		-- Vowel changes before Q1/Q2
		if form.quantity < 3 then
			if form.svowel == "eä" then
				form.svowel = "iä"
			end
		else
			if form.svowel == "ie" or form.svowel == "iä" then
				form.svowel = "eä"
			end
		end
		
		if vowel_effect == "L" then
			if form.svowel == "i" then
				form.svowel = "ï"
			elseif form.svowel == "ü" then
				form.svowel = "u"
			elseif form.svowel == "ie" then
				form.svowel = "iä"
			elseif form.svowel == "uö" then
				form.svowel = "ua"
			end
		elseif vowel_effect == "R" then
			if form.svowel == "iä" then
				form.svowel = "ie"
			end
		elseif vowel_effect == "I" then
			if form.svowel == "a" then
				form.svowel = "e"
			elseif form.svowel == "ï" then
				form.svowel = "i"
			elseif form.svowel == "u" or form.svowel == "å" then
				form.svowel = "ü"
			elseif form.svowel == "á" then
				form.svowel = "ä"
			elseif form.svowel == "eä" or form.svowel == "ie" or form.svowel == "iä" then
				form.svowel = "ē"
			elseif form.svowel == "ua" or form.svowel == "uö" then
				form.svowel = "ue"
			elseif form.svowel == "å̄" then
				form.svowel = "ǖ"
			end
		elseif vowel_effect == "U" then
			if form.svowel == "a" then
				form.svowel = "å"
			elseif form.svowel == "i" or form.svowel == "ï" then
				form.svowel = "y"
			elseif form.svowel == "ü" or form.svowel == "å" then
				form.svowel = "u"
			elseif form.svowel == "á" then
				form.svowel = "å̄"
			elseif form.svowel == "eä" or form.svowel == "ie" or form.svowel == "iä" then
				form.svowel = "yö"
			elseif form.svowel == "ua" or form.svowel == "uö" then
				form.svowel = "ū"
			end
		end
	end,
}

export.Stem = require("Module:smi-common").make_constructor(langdata)

return export