This module implements the {{kl-IPA}}
template.
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 = {
= "ŋŋ",
= "ŋ",
= "ɡ",
= "t",
= "p",
= "i",
= "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, "(-)(n??)", "%1.%2")
word = gsub(word, "()%.%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, "()%1", "%1ː")
-- /ɡ/-allophony
word = gsub(word, "ig%.g", "iç.ç")
word = gsub(word, "ag%.g", "ax̟.x̟")
-- /u/-labialisation
word = gsub(word, "u(ː?)%.v?()", "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%.()", "ʶːr.%1")
-- Vowel allophone changes
-- U
word = gsub(word, "u(ʶ?" .. vowelBound .. ")", "O%1")
word = gsub(word, "()u(" .. vowelBound .. ")", "%1ʉ%2")
word = gsub(word, "u(" .. vowelBound .. ")", "u%1")
word = gsub(word, "u(" .. vowelBound .. ")", "ʊ%1")
word = gsub(word, "#ʊ(" .. vowelBound .. ")", "#u%1")
-- A
word = gsub(word, "a(ʶ?" .. vowelBound .. ")", "ɑ%1")
word = gsub(word, "a(" .. vowelBound .. ")", "ə%1")
word = gsub(word, "#ə(" .. vowelBound .. ")", "#a%1")
-- I
word = gsub(word, "i(ʶ?" .. vowelBound .. ")", "ɐ%1")
word = gsub(word, "i(" .. vowelBound .. ")", "y%1")
word = gsub(word, "i(" .. vowelBound .. ")", "ɪ%1")
word = gsub(word, "#ɪ(" .. vowelBound .. ")", "#i%1")
-- Geminates
local mapGL = {
= "x",
= "ɬ",
= "χ",
= "f"
}
word = gsub(word, "r%.()", "%1.%1")
word = gsub(word, "n%.ŋ", "ŋ.ŋ")
word = gsub(word, "()%.%1", function(c) return mapGL .. "." .. mapGL end)
-- Substitute monographs
local mapML = {
= "ɣ",
= "ɜ",
= "ɔ", -- FIXME: don't substitute twice
= "o",
= "ʁ",
= "t",
= "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 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 = "" })
end
return acc.format_qualifiers(lang, {"]"}) .. ' ' .. ipa.format_IPA_full { lang = lang, items = results }
end
return export