Module:kl-pron/sandbox
Jump to navigation
Jump to search
- This module sandbox lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox of (diff)
local export = {}
export.phonetic = function(frame)
local params = { [1] = {} }
local args = require("Module:parameters").process(frame:getParent().args, params)
local word = ""
if args[1] == nil or args[1] == "" then
word = mw.title.getCurrentTitle().subpageText
else
word = args[1]
end
word = word:lower()
-- Trigraphs and retracted /a/
local map3L = { ["nng"] = "ŋ.ŋ", ["aar"] = "ɑːr", ["aaq"] = "ɑːq" }
-- Digraphs and retracted /a/
local map2L = { ["ng"] = "ŋ", ["aa"] = "aː", ["ee"] = "ɜː",
["ii"] = "iː", ["oo"] = "ɔː", ["uu"] = "uː",
["ar"] = "ɑr", ["aq"] = "ɑq" }
-- Geminates and /t/-affrication
local mapGL = { ["ll"] = "ɬ.ɬ", ["gg"] = "x.x", ["rr"] = "χ.χ",
["rl"] = "ɬ.ɬ", ["gg"] = "x.x", ["rf"] = "f.f",
["ff"] = "f.f", ["pp"] = "p.p", ["nn"] = "n.n",
["mm"] = "m.m", ["tt"] = "t.t", ["qq"] = "q.q",
["ss"] = "s.s", ["kk"] = "k.k", ["ts"] = "t.t͡s",
["ti"] = "t͡si", ["rn"] = "n.n", ["rm"] = "m.m",
["rp"] = "p.p", ["rt"] = "t.t", ["rk"] = "k.k" }
-- Monographs
local map1L = { ["g"] = "ɣ", ["e"] = "ɜ", ["o"] = "ɔ", ["r"] = "ʁ", ["'"] = "ˈ" }
local vow = {"a", "e", "i", "o", "u"}
for I = 1, #word do
local let0 = word:sub(I, I)
local let1 = word:sub(I + 1, I + 1)
local let2 = word:sub(I + 2, I + 2)
if contains(let0, vow) and let1 ~= " " and contains(let2, vow) then
word = word:sub(1, I) .. "." .. word:sub(I + 1)
elseif contains(let0, vow) and contains(let1, vow) and let0 ~= let1 then
word = word:sub(1, I) .. "." .. word:sub(I + 1)
end
end
for let, res in pairs(map3L) do
word = mw.ustring.gsub(word, let, res)
end
for let, res in pairs(map2L) do
word = mw.ustring.gsub(word, let, res)
end
for let, res in pairs(mapGL) do
word = mw.ustring.gsub(word, let, res)
end
for let, res in pairs(map1L) do
word = mw.ustring.gsub(word, let, res)
end
word = mw.ustring.gsub(word, "ː.", "ː")
return "[" .. word .. "]"
end
function contains(key, set)
for k0, val in pairs(set) do
if val == key then
return true
end
end
return false
end
return export