Module:kl-pron

local export = {}

local lang = require("Module:languages").getByCode("kl") local ipa = require("Module:IPA") local acc = require("Module:accent qualifier")

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

-- Letter groups local consGroup = "mnptkqvsgrljfbd" local vowelGroup = "aeiou" local uvular = "rq" local labial = "mp" local alveolar = "ntsl" local vowelBound = "ː?%.?"

-- Phonemic transcription function export.phonemic(word) -- Make text lowercase word = lower(word)

-- Phonemic changes local mapPL = { ["nng"] = "ŋŋ", ["ng"] = "ŋ", ["g"] = "ɡ", ["d"] = "t", ["b"] = "p", ["e"] = "i", ["o"] = "u" }	word = gsub(word, "n*.", mapPL) word = gsub(word, ".", mapPL) -- Repeat to capture all remaining characters

return word end

-- Syllabification rules function export.syllabify(word, hide_borders) -- Mark all word borders with # word = gsub(word, "([^ ]+)", "#%1#")

word = gsub(word, "([^" .. consGroup .. "]-)(n?[" .. consGroup .. "]?[" .. vowelGroup .. "])", "%1.%2")	word = gsub(word, "([" .. vowelGroup .. "])%.%1", "%1%1")	word = gsub(word, "%.nn", "n.n") word = gsub(word, "(#%-?)%.", "%1")

return hide_borders and gsub(word, "#", "") or word end

-- Phonetic transcription function export.phonetic(word) -- Make text lowercase word = lower(word)

-- Syllabify the word word = export.syllabify(word, false)

-- NG	word = gsub(word, "ng", "ŋ")

-- long vowels word = gsub(word, "([" .. vowelGroup .. "])%1", "%1ː")

-- /ɡ/-allophony word = gsub(word, "ig%.g", "iç.ç") word = gsub(word, "ag%.g", "ax̟.x̟")

-- /u/-labialisation word = gsub(word, "u(ː?)%.v?([" .. vowelGroup .. "])", "u%1.ʷ%2")

-- /t/-affrication word = gsub(word, "ti", "t͡si") word = gsub(word, "t%.s", "t.t͡s")

-- word-initial G is voiceless word = gsub(word, "#g", "#k")

-- Vowel uvularisation word = gsub(word, "ːr%.([" .. consGroup .. "])", "ʶːr.%1")

-- Vowel allophone changes -- U	word = gsub(word, "u(ʶ?" .. vowelBound .. "[" .. uvular .. "])", "O%1") word = gsub(word, "([" .. alveolar .. "])u(" .. vowelBound .. "[" .. alveolar .. "])", "%1ʉ%2") word = gsub(word, "u(" .. vowelBound .. "[" .. labial .. "])", "u%1") word = gsub(word, "u(" .. vowelBound .. ")", "ʊ%1") word = gsub(word, "#ʊ(" .. vowelBound .. "[^" .. uvular .. "])", "#u%1")

-- A	word = gsub(word, "a(ʶ?" .. vowelBound .. "[" .. uvular .. "])", "ɑ%1") word = gsub(word, "a(" .. vowelBound .. "[^#])", "ə%1") word = gsub(word, "#ə(" .. vowelBound .. "[^" .. uvular .. "])", "#a%1")

-- I	word = gsub(word, "i(ʶ?" .. vowelBound .. "[" .. uvular .. "])", "ɐ%1") word = gsub(word, "i(" .. vowelBound .. "[" .. labial .. "])", "y%1") word = gsub(word, "i(" .. vowelBound .. ")", "ɪ%1") word = gsub(word, "#ɪ(" .. vowelBound .. "[^" .. uvular .. "])", "#i%1")

-- Geminates local mapGL = { ["g"] = "x", ["l"] = "ɬ", ["r"] = "χ", ["v"] = "f" }	word = gsub(word, "r%.([lfsnmptk])", "%1.%1") word = gsub(word, "n%.ŋ", "ŋ.ŋ") word = gsub(word, "([glrv])%.%1", function(c) return mapGL[c] .. "." .. mapGL[c] end)

-- Substitute monographs local mapML = { ["g"] = "ɣ", ["e"] = "ɜ", ["o"] = "ɔ", -- FIXME: don't substitute twice ["O"] = "o", ["r"] = "ʁ", ["d"] = "t", ["b"] = "p", ["'"] = "ˈ" }	word = gsub(word, ".", mapML)

-- Remove word boundaries return gsub(word, "#", "") end

-- Display pronunciation function export.show(frame) local args = frame:getParent.args local pagetitle = mw.title.getCurrentTitle.text

local p, results = {}, {}

if args[1] then for _, v in ipairs(args) do			table.insert(p, (v ~= "") and v or nil) end else p = { pagetitle } end

for _, word in ipairs(p) do		word = (word == "kl-IPA") and "avinngaq" or word

local phonemic = export.phonemic(word) local phonetic = export.phonetic(word)

table.insert(results, { pron = "/" .. phonemic .. "/" }) table.insert(results, { pron = "[" .. phonetic .. "]" }) end

return acc.format_qualifiers(lang, {"Nuuk"}) .. ' ' .. ipa.format_IPA_full { lang = lang, items = results } end

return export