Module:siwa-pron: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 74: Line 74:
end
end
end
end
table.insert(IPA, term)
if not find(term, "·") then
if not find(term, "·") then
table.concat("ˈ", IPA)
table.insert(IPA, "ˈ")
end
end
table.insert(IPA, term)
if find(term, "·") then
if find(term, "·") then

Revision as of 23:36, 2 January 2021



local export = {}
	
local m_IPA = require("Module:IPA")
local m_su = require("Module:string utilities")
local m_table = require("Module:table")
local m_sm = mw.loadData('Module:siwa-pron/data')

local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub

local rules = {
	{	--long consonants
		["mm"] = "mː",
		["bb"] = "pː",
		["vv"] = "wː",
		["nn"] = "nː",
		["dd"] = "tː",
		["ḍḍ"] = "ðː",
		["ss"] = "sː",
		["ṡṡ"] = "ɕː",
		["ddį"] = "d͡ʑː",
		["gį"] = "jː",
		["rr"] = "rː",
		["ll"] = "lː",
		["gg"] = "kː",
		["ġġ"] = "xː",
		["ng"] = "ŋː",
		["hh"] = "hː",
		["ḥḥ"] = "ʔː",
	},
	{	--consonants not affected by stress
		["ṡ"] = "ɕ",
		["tṡ"] = "t͡ɕ",
		["dį"] = "d͡ʑ",
		["ḍ"] = "ð",
		["dl"] = "tɬ",
		["ng"] = "ŋː",
		["nį"] = "ɲ",
		["ġ"] = "x",
	},
	{	--long vowels and o remain unchanged
		["ẻu"] = "øː",
		["õu"] = "ɔ̃ː̃",
		["õ"] = "ɔ̃",
		["ả"] = "æː",
		["ẻ"] = "eː",
		["ỉ"] = "iː",
		["ỏ"] = "ʊː",
		["o"] = "ɔ",
		["ủ"] = "uː",
		["ỷ"] = "yː",
	},
	--voiceless stops word-initially become aspirated
	{["(^[ptk])"] = "%1ʰ"},
}

local consonant = "[" .. "mpbvntdsṡrklgġhįų" .. "]"
local vowel = "[" .. "aæɑeɛiɪɔʊyœøɤ" .. "]"

--[[function export.syllable(frame)
	local word = mw.title.getCurrentTitle().text
	local pattern = "^[" .. initial .. "]?[" .. vocalic .. "]{1}[" .. internal .. "]?"
	x = m_su.capturing_split(word, pattern)
	return x[1]
end]]

function export.crux(term)
	local IPA = {}
	for _, rule in ipairs(rules) do
		for regex, replacement in pairs(rule) do
			term = gsub(term, regex, replacement)
		end
	end
	
	if not find(term, "·") then
		table.insert(IPA, "ˈ")
	end
	
	table.insert(IPA, term)
	
	if find(term, "·") then
		morphemes = {}
		morphemes = mw.text.split(term, "·")
		for _, morpheme in ipairs(morphemes) do
			print(morphemes[morpheme])
		end
	end
	
	return term
end

function export.show(frame)
	local parent_args = frame:getParent().args
	local params = {
		[1] = { default = mw.title.getCurrentTitle().text },
	}
	local args = require("Module:parameters").process(parent_args, params)
	local term = args[1]
	
	local ipa = export.crux(term)
	
	local IPA_key = "IPA for Siwa"
	local key_link = "[[".. IPA_key .."|key]]"

	local prefix = "[[w:IPA chart|IPA]]<sup>(" .. key_link .. ")</sup>:&#32;"
	local accent="(\''Aingo\'') "
	
	ipa = "<span style=\"font-size:110%;font-family:Gentium,'DejaVu Sans','Segoe UI',sans-serif>[" .. ipa .. "]</span>"
	ipa = accent..prefix..ipa
	
	return ipa
end

return export