This is a private module sandbox of Thadh, for their own experimentation. Items in this module may be added and removed at Thadh's discretion; do not rely on this module's stability.
local export = {}
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("csb")
local rsub = mw.ustring.gsub
local rlower = mw.ustring.lower
local F = ""
local C = ""
local V = ""
local Vi = ""
local T = ""
local D = ""
local di = {
="x", ="tʃ", ="r̝", ="ʃ",
}
local phon = {
="a", ="õ", ="ã", ="b",
="ts", ="d", ="ɛ", ="e",
="ə", ="f", ="ɡ", ="x",
="i", ="j", ="k", ="l",
="w", ="m", ="n", ="ɲ",
="ɔ", ="wɛ", ="o", ="ɞ",
="p", ="r", ="s", ="t",
="u", ="wu", ="v", ="i",
="z", ="ʒ",
}
local function phonemic(text)
text = rlower(text)
-- basic phonology
text = rsub(text, "..", di)
text = rsub("1" .. text, "..", di)
text = rsub(text, "1", "")
text = rsub(text, ".", phon)
text = rsub(text, "n()", "ŋ%1")
text = rsub(text, "(o", "%1wo")
text = rsub(text, "vw", "w")
-- palatalisation
text = rsub(text, "(" .. C .. ")i(" .. V .. ")", "%1j%2")
text = rsub(text, "r̝i(" .. V .. ")", "r̝j%2")
text = rsub(text, "(" .. C .. ")(" .. F .. ")", "%1ʲ%2")
text = rsub(text, "r̝(" .. F .. ")", "r̝ʲ%2")
text = rsub(text, "nʲ", "ɲ")
text = rsub(text, "ʃʲ", "ɕ")
text = rsub(text, "ʒʲ", "ʑ")
-- voicing
text = rsub(text, "b(r̝)$", "p%1")
text = rsub(text, "d(r̝)$", "t%1")
text = rsub(text, "ɡ(r̝)$", "k%1")
text = rsub(text, "z(r̝)$", "s%1")
text = rsub(text, "v(r̝)$", "f%1")
text = rsub(text, "ʒ(r̝)$", "ʃ%1")
text = rsub(text, "ʑ(r̝)$", "ɕ%1")
text = rsub(text, "r̝$", "r̝̊")
while i <= 5 do
text = rsub(text, "b(" .. T .. ")", "p%1%2")
text = rsub(text, "d(" .. T .. ")", "t%1%2")
text = rsub(text, "ɡ(" .. T .. ")", "k%1%2")
text = rsub(text, "z(" .. T .. ")", "s%1%2")
text = rsub(text, "v(" .. T .. ")", "f%1%2")
text = rsub(text, "ʒ(" .. T .. ")", "ʃ%1%2")
text = rsub(text, "ʑ(" .. T .. ")", "ɕ%1%2")
text = rsub(text, "p(" .. D .. ")", "b%1%2")
text = rsub(text, "t(" .. D .. ")", "d%1%2")
text = rsub(text, "k(" .. D .. ")", "ɡ%1%2")
text = rsub(text, "s(" .. D .. ")", "z%1%2")
text = rsub(text, "f(" .. D .. ")", "v%1%2")
text = rsub(text, "ʃ(" .. D .. ")", "ʒ%1%2")
text = rsub(text, "ɕ(" .. D .. ")", "ʑ%1%2")
end
text = rsub(text, "(" .. T .. ")r̝", "%1r̝̊")
-- stress
if mw.ustring.find(text, "'") == nil then
text = "ˈ" .. text
end
text = rsub(text, "(" .. Vi .. ")'", "'%1")
text = rsub(text, "^(" .. C .. ")*'", "'%1")
text = rsub(text, "(" .. C .. ")'", "%1'")
text = rsub(text, "'", "ˈ")
-- affricates
text = rsub(text, "t()", "t͡%1")
text = rsub(text, "d()", "d͡%1")
return text
end
function export.IPA(frame)
local words = {}
for _, word in ipairs(frame:getParent().args) do
table.insert(words, word)
end
if #words == 0 then
words = {mw.title.getCurrentTitle().text}
end
local IPA_results = {}
for _, word in ipairs(words) do
table.insert(IPA_results, { pron = "/" .. phonemic(word) .. "/" })
end
return m_IPA.format_IPA_full { lang = lang, items = IPA_results }
end
return export