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 u = mw.ustring.char
local UNRELEASED = u(0x031A) -- COMBINING LEFT ANGLE ABOVE. ̚
local NASALIZED = u(0x0303) -- COMBINING TILDE. ̃
--obsolete ligatures and L with stroke used to remove two-character hassle. will replace later
local consonant = "[mnɲŋpbtdcɟkɡʔvðsɕxɣhʨʥɾlɬłʣjw]" .. UNRELEASED .. "?"
local front_vowel = "iɪyeøɛœæa"
local back_vowel = "uɔ" .. NASALIZED .. "?ɑʊ"
local vowel = "[" .. front_vowel .. back_vowel .. "]"
local open_to_closed = {["ɑ"] = "a", ["e"] = "ɛ", ["i"] = "ɪ", ["u"] = "ʊ", ["y"] = "œ", ["ø"] = "œ",}
local rules = {
{ --long consonants
["mm"] = "mː",
["bb"] = "pː",
["vv"] = "wː",
["nn"] = "nː",
["dd"] = "tː",
["ḍḍ"] = "ðː",
["ss"] = "sː",
["ṡṡ"] = "ɕː",
["ddį"] = "ʥː",
["rr"] = "rː",
["ll"] = "lː",
["gg"] = "kː",
["ġġ"] = "xː",
["ng"] = "ŋː",
["hh"] = "hː",
["ḥḥ"] = "ʔː",
},
{ --consonants not affected by stress
["ṡ"] = "ɕ",
["tṡ"] = "ʨ",
["dį"] = "ʥ",
["ḍ"] = "ð",
["dl"] = "tɬ",
["ng"] = "ŋː",
["nį"] = "ɲ",
["ġ"] = "x",
},
{ --all vowels as open (open-closed distinctions are computed later)
["a"] = "ɑ", ["ả"] = "æː",
["ę"] = "æ",
["ẻ"] = "eː",
["ỉ"] = "iː",
["o"] = "ɔ", ["ỏ"] = "ʊː",
["ủ"] = "uː",
["ỷ"] = "yː",
["ů"] = "ø", ["ẻu"] = "øː",
["õ"] = "ɔ̃", ["õu"] = "ɔ̃ː̃",
},
{
["^k([" .. front_vowel .. "])"] = "c%1", --word-initial [k] palatalizes before front-vowels
["^([ptkc])"] = "%1ʰ", --voiceless stops word-initially become aspirated
["^gį([" .. front_vowel .. "])"] = "ʣ%1", --<gį> word-initially and before front vowels is pronounced [d͡z]
},
{["(" .. vowel .. ")(" .. vowel .. ")(" .. vowel .. ")(" .. consonant .. consonant .. ")"] = open_to_closed["%1"] .. open_to_closed["%2"] .. open_to_closed["%3"] .. "%4"
},
{
["(" .. vowel .. ")t$"] = "%1ʔ%1" -- -Vt becomes -VʔV (or -Vht, not considered)
},
}
--[[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 = {}
term=mw.ustring.lower(term)
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]]
IPA = table.concat(IPA)
return IPA
end
function export.show(frame)
local parent_args = frame:getParent().args
local params = {
[1] = { default = mw.title.getCurrentTitle().nsText == 'Template' and "uįo·sauṡṡi" or 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>: "
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