Module:sje-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áeiouūyåäAÁEIOUŪYÅÄ" .. mw.ustring.char(0x0304) .. "{}-]*)$",
	},
	vowel = {
		"^(.-)(u[aoä])$",
		"^(.-)(å̄)$",
		"^(.-)(ie)$",
		"^(.-)([aáeiouūyåäAÁEIOUŪYÅÄ]?)$",
	},
	scons = {
		[1] = {
		},
		[2] = {
			{"^bm$", "m", "bbm"},
			{"^dn(j?)$", "n%1", "ddn%1"},
			{"^gŋ$", "ŋ", "ggŋ"},
			{"^dd$", "d", "dˈd"},
			{"^dj$", "j", "ddj"},
			{"^([fjlmnŋ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"},
			
			{"^(b)%1([n])$", "%1%2"},
			{"^(j)%1([bgkrt])$", "%1%2"},
			{"^(k)%1([st])$", "%1%2"},
			{"^(k)%1(sj)$", "%1%1"},
			{"^(l)%1([dgjv])$", "%1%2"},
			{"^(n)%1([dt])$", "%1%2"},
			{"^(p)%1([t])$", "%1%2"},
			{"^(r)%1([bdgjkt])$", "%1%2"},
			{"^(s)%1([knt])$", "%1%2"},
			{"^(v)%1([l])$", "%1%2"},
			
			{"^jbm$", "jm"},
			{"^lbm$", "lm"},
			{"^ldn$", "ln"},
		},
	},
	vowel_variants = {
		normal = {["e"] = {"e", "F"}                    },
		e      = {["e"] = {"á", "L"}, ["o"] = {"u", "R"}},
		j      = {["e"] = {"i", "R"},                   },
		je     = {["e"] = {"i", "R"}, ["o"] = {"u", "R"}},
	},
	postprocess = function(form, vowel_effect)
		-- Vowel changes before Q1/Q2
		if form.quantity < 3 then
			if form.svowel == "ua" or form.svowel == "uä" then
				form.svowel = "uo"
			elseif form.svowel == "ä" then
				form.svowel = "ie"
			end
		else
			if form.svowel == "uo" then
				form.svowel = "ua"
			elseif form.svowel == "ie" then
				form.svowel = "ä"
			end
		end
		
		-- Fronting/backing/raising
		if vowel_effect == "F" and form.svowel == "ua" then
			form.svowel = "uä"
		elseif vowel_effect == "B" and form.svowel == "uä" then
			form.svowel = "ua"
		elseif vowel_effect == "R" then
			if form.svowel == "á" then
				form.svowel = "ä"
			elseif form.svowel == "uo" or form.svowel == "ua" or form.svowel == "uä" or form.svowel == "å̄" then
				form.svowel = "ū"
			elseif form.svowel == "ie" or form.svowel == "ä" then
				form.svowel = "e"
			elseif form.svowel == "a" then
				form.svowel = "i"
			end
		end
	end,
}

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

return export