Module:qay-pron: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(44 intermediate revisions by the same user not shown)
Line 14: Line 14:
local export = {}
local export = {}


local consonants = "[pbmvstdnrɾlkɡŋhxçʤʧjwçx]"
local consonants = "[pbmvstdnrɾlkɡŋhxçʤʧjwçx2]"
local front = "iɪeɛ"
local front = "iɪeɛ"
local back = "oɔu"
local back = "oɔuʊ"
local vowels = "[a" .. front .. back .. "ː´]"
local vowels = "[a" .. front .. back .. "ː´2]"


local function laxen(v)
local function laxen(v)
local otc = {}
local otc = {}
local switch = {["e"] = "ɛ", ["i"] = "ɪ", ["o"] = "ɔ", ["u"] = "ʊ", ["a"] = "a", ["ː"] = "ː"}
local switch = {["e"] = "ɛ", ["i"] = "ɪ", ["o"] = "ɔ", ["u"] = "ʊ"}
 
 
for vc in gmatch(v, ".") do
for vc in gmatch(v, ".") do
vc = gsub(vc, vc, switch[vc])
if switch[vc] then vc = gsub(vc, vc, switch[vc]) end
table.insert(otc, vc)
table.insert(otc, vc)
end
end
Line 37: Line 37:


local first_rules = {
local first_rules = {
{"n(·?)([kg])", "ŋ%1%2"}, {"ŋg", "ŋ"}, {"c", "ʧ"}, {"j", "ʤ"}, {"y", "j"}, {"g", "ɡ"},  
{"n(·?)([kg])", "ŋ%1%2"}, {"ŋg", "ŋ"}, {"c", "ʧ"}, {"j", "ʤ"}, {"y", "j"}, {"g", "ɡ"}, {"%-", ""},
-- Long vowels
-- Long vowels
{"ā", "aː"},  {"ē", "eː"}, {"ī", "iː"}, {"ō", "oː"}, {"ū", "uː"},
{"ā", "aː"},  {"ē", "eː"}, {"ī", "iː"}, {"ō", "oː"}, {"ū", "uː"},
-- Diphthongs
-- Diphthongs
{"au", "aʊ"}, {"[uʊ]ji", "wi"}
{"au", "aʊ"}, {"[uʊ]ji", "wi"}, {"h?u([aeiouɛɪɔʊ])", "w%1"},
}
}


local phonetic_rules = {
local phonetic_rules = {
{"ˈ·", "ˈ"}, {"·ˈ", "ˈ"},
{"([ˈˌ])·", "%1"}, {"·([ˈˌ])", "%1"}, {"ˈˌ", "ˌ"}, {"·ˈ´·", "ˈ"},
{"h?u([aeiouɛɪɔʊ])", "w%1"}, {"h([" .. front .. "])", "ç%1"}, {"h([" .. back .. "])", "x%1"},
{"h([" .. front .. "])", "ç%1"}, {"h([" .. back .. "])", "x%1"},
{"([^nŋ]·)[tk]j", "%1ʧ"}, {"([^nŋ]·)[dɡ]j", "%1ʤ"}, {"r", "ɾ"},
{"([^nŋ]·)[tk]j", "%1ʧ"}, {"([^nŋ]·)[dɡ]j", "%1ʤ"}, {"r", "ɾ"}, {"k([·ˈ])w", "%1kw"}, {"s([·ˈ])j", "%1sj"},
-- Lax vowels in closed syllables
-- Lax vowels in closed syllables
Line 63: Line 63:
{"(·" .. consonants .. ")e$", "%1ə"}, {"a", "ä"},
{"(·" .. consonants .. ")e$", "%1ə"}, {"a", "ä"},
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"},
}
}


local function syllabify(term)
local function syllabify(word)
term = gsub(term, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
word = gsub(word, "2", "ˌ")
term = gsub(term, "··", "·"); term = gsub(term, "·$", ""); term = gsub(term, "^·", "")
word = gsub(word, "(ː)(" .. vowels .. ")", "%1·%2")
term = gsub(term, "·(" .. consonants .. ")(" .. consonants .. ")(" .. vowels .. "*)", "%1·%2%3")
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
term = gsub(term, "·(" .. consonants .. ")$", "%1")
word = gsub(word, "··", "·"); word = gsub(word, "·$", ""); word = gsub(word, "^·", "")
term = gsub(term, "·(" .. consonants .. ")·", "%1·")
word = gsub(word, "·(" .. consonants .. ")(" .. consonants .. ")(" .. vowels .. "*)", "%1·%2%3")
term = gsub(term, "(" .. consonants .. ")·(" .. consonants .. ")([pbmvstdnrɾlkɡŋhxçʤʧ])", "%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(term, "·")
local syllables = split(word, "·");
if #syllables ~= 1 then
if #syllables ~= 1 then
for i, syll in ipairs(syllables) do
for i, syll in ipairs(syllables) do
if match(syll, "´") or match(syll, "ː") then
if match(word, "´") and not match(syll, "´") then
break
elseif match(syll, "´") then
syll = syll:gsub("´","ˈ")
return table.concat(syllables, "·")
elseif match(syll, "ː") then
table.insert(syllables, i, "ˈ")
table.insert(syllables, i, "ˈ")
return table.concat(syllables, "·")
return table.concat(syllables, "·")
elseif match(term, "ŋ$") or match(syllables[#syllables], "[aɛɪɔʊ][ɪʊ]") then
elseif match(word, "ŋ$") or match(syllables[#syllables], "[aeiouɛɪɔʊ][aeiouɛɪɔʊj]") then
table.insert(syllables, #syllables, "ˈ")
table.insert(syllables, #syllables, "ˈ")
--syllables[#syllables-1] = gsub(syllables[#syllables-1], "ˈ", "")
return table.concat(syllables, "·")
return table.concat(syllables, "·")
else
--[[else
table.insert(syllables, #syllables-1, "ˈ")
table.insert(syllables, #syllables-1, "ˈ")
return table.concat(syllables, "·")
return ret]]
end
end
end
local ret = table.concat(syllables, "·");
if not match(ret, "ˈ") then
syllables = split(ret, "·")
syllables[#syllables - 1] = "ˈ" .. syllables[#syllables - 1]
ret = table.concat(syllables, "·")
end
end
end
end
Line 103: Line 119:
term = syllabify(term)
term = syllabify(term)
for _, micrule in ipairs(phonetic_rules) do
for _, rule in ipairs(phonetic_rules) do
term = gsub(term, micrule[1], micrule[2])
term = gsub(term, rule[1], rule[2])
end
end
term = gsub(term, "·", ".")
term = gsub(term, "·", ".")
term = gsub(term, "%.%.", ".")
return term
return term
end
function separate_word(term)
local result = {}
for word in gsplit(term, " ") do
table.insert(result, export.crux(word))
end
return table.concat(result, " ")
end
end


Line 121: Line 148:


local IPA_args = {}
local IPA_args = {}
local phonetic = export.crux(term)
local phonetic = separate_word(term)
table.insert(IPA_args, {pron = '[' .. phonetic .. ']'})
table.insert(IPA_args, {pron = '[' .. phonetic .. ']'})