Module:qlu-pron: Difference between revisions

Created page with "local sub = mw.ustring.sub local find = mw.ustring.find local gmatch = mw.ustring.gmatch local gsub = mw.ustring.gsub local match = mw.ustring.match local u = mw.ustring.char local split = mw.text.split local gsplit = mw.text.gsplit local lang = require("Module:languages").getByCode("qlu") local m_table = require("Module:table") local m_IPA = require("Module:IPA") local export = {} local consonants = "[mnɲŋptkbdɡɸfsθʃxβvzðɣʦʧʣʤlʎrɹɾʁʒʈ]" local front..."
 
No edit summary
Line 14: Line 14:
local export = {}
local export = {}


local consonants = "[mnɲŋptkbdɡɸfsθʃxβvzðɣʦʧʣʤlʎrɹɾʁʒʈ]"
local consonants = "[mnɲŋptkbdɡɸfsθʃxβvzðɣʦʧʣʤlʎrɹɾʁʒʈʷʨʥḱːjw]"
local front = "ieɛɪ"
local front = "ieɛɪæyʏøœ"
local back = "uoɔʊ"
local back = "uoɔʊʌɑɒ"
local vowels = "[aɐ" .. front .. back .. "ː´]"
local vowels = "[aɐ" .. front .. back .. "ːjw]"


local function laxen(v)
local function laxen(v)
Line 37: Line 37:


local first_rules = {
local first_rules = {
{"sc([ei])", "ʃ%1"}, {"c([ei])", "ʧ%1"}, {"g([ei])", "ʤ%1"}, {"%-", ""},
{"sc([ei])", "ʃ%1"}, {"c([ei])", "ʧ%1"}, {"g([ei])", "ʤ%1"}, {"gu", "ǵ"}, {"%-", ""},
{"ch", "k"}, {"gh", "g"}, {"ph", "ɸ"}, {"th", "ʈ"}, {"h", ""},
{"ch?", "k"}, {"g([cqg])", "ŋ%1"}, {"gli", "ʎi"}, {"gni", "ɲi"},
{"gh?", "ɡ"}, {"ph", "ɸ"}, {"th", "ʈ"}, {"h", ""},
{"qu?", "ḱ"}, {"z", "ʦ"}, {"þ", "θ"},
{"g", "ɡ"},
{"ae", "ɛ"}, {"au", "ɔ"}, {"ei", "i"},
}
}


local phonetic_rules = {
local phonetic_rules = {
{"([ˈˌ])·", "%1"}, {"·([ˈˌ])", "%1"}, {"ˈˌ", "ˌ"}, {"·ˈ´·", "ˈ"},
 
}
{"h([" .. front .. "])", "ç%1"}, {"h([" .. back .. "])", "x%1"},
 
{"([^nŋ]·)[tk]j", "%1ʧ"}, {"([^nŋ]·)[dɡ]j", "%1ʤ"}, {"r", "ɾ"}, {"k([·ˈ])w", "%1kw"}, {"s([·ˈ])j", "%1sj"},
local last_rules = {
-- Escaped characters
-- Lax vowels in closed syllables
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"},
{"([·ˈ])(" .. consonants .. "?)(" .. vowels .. "*)(" .. consonants .. ")", function(st,c1,v,c2) return st .. c1 .. laxen(v) .. c2 end},
{"", ""}, {"ǵ", "ɡʷ"}, {"ʈ", "t"},
{"^(" .. consonants .. "?)(" .. vowels .. "*)(" .. consonants .. ")$", function(c1,v,c2) return c1 .. laxen(v) .. c2 end},
{"(" .. consonants .. ")(" .. vowels .. "*)(" .. consonants .. consonants .. ")", function(c1,v,c23) return c1 .. laxen(v) .. c23 end},
-- Doubled consonants are reduced to one
{"(" .. consonants .. ")(·?ˈ?)(" .. consonants .. ")", function(c1, st, c2) return same(c1,c2) and st .. c1 or c1 .. st .. c2 end},
{"jj", "j"},
-- Diphthongs
{"(" .. vowels .. ")j$", "%1ɪ"},
{"(·" .. consonants .. ")e$", "%1ə"}, {"a", "ä"},
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"},
}
}


local function syllabify(word)
local function syllabify(word)
word = gsub(word, "2", "ˌ")
word = gsub(word, "(" .. consonants .. "?" .. consonants .. "?" .. consonants .. "?" .. vowels .. "?" .. vowels .. vowels .. "?" .. consonants .. "?" .. consonants .. "?)", "·%")
word = gsub(word, "(ː)(" .. vowels .. ")", "%1·%2")
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
word = gsub(word, "··", "·"); word = gsub(word, "·$", ""); word = gsub(word, "^·", "")
word = gsub(word, "·(" .. consonants .. ")(" .. consonants .. ")(" .. vowels .. "*)", "%1·%2%3")
word = gsub(word, "·(" .. consonants .. ")$", "%1")
word = gsub(word, "·(" .. consonants .. ")·", "%1·")
word = gsub(word, "(" .. consonants .. ")·(" .. consonants .. ")([pbmvstdnrɾlkɡŋhxçʤʧçx])", "%1%2·%3")
word = gsub(word, "a·ʊ", "aʊ·")
local syllables = split(word, "·");
local syllables = split(word, "·");
Line 80: Line 62:
if #syllables ~= 1 then
if #syllables ~= 1 then
for i, syll in ipairs(syllables) do
for i, syll in ipairs(syllables) do
if match(word, "´") and not match(syll, "´") then
table.insert(syllables, #syllables-1, "ˈ")
break
elseif match(syll, "´") then
return ret
syll = syll:gsub("´","ˈ")
return table.concat(syllables, "·")
elseif match(syll, "ː") then
table.insert(syllables, i, "ˈ")
return table.concat(syllables, "·")
elseif match(word, "ŋ$") or match(syllables[#syllables], "[aeiouɛɪɔʊ][aeiouɛɪɔʊj]") then
table.insert(syllables, #syllables, "ˈ")
return table.concat(syllables, "·")
--[=[else
table.insert(syllables, #syllables-1, "ˈ")
return ret]=]
end
end
end
Line 116: Line 86:
end
end
--term = syllabify(term)
term = syllabify(term)
--[[for _, rule in ipairs(phonetic_rules) do
term = gsub(term, rule[1], rule[2])
end]]
term = gsub(term, "·", ".")
term = gsub(term, "%.%.", ".")
for _, rule in ipairs(phonetic_rules) do
for _, rule in ipairs(last_rules) do
term = gsub(term, rule[1], rule[2])
term = gsub(term, rule[1], rule[2])
end
end
--term = gsub(term, "·", ".")
--term = gsub(term, "%.%.", ".")
return term
return term