45,647
edits
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
local consonants = "[pbmvstdnrɾlkɡŋhxçʤʧj]" | local consonants = "[pbmvstdnrɾlkɡŋhxçʤʧj]" | ||
local front = " | local front = "iɪeɛ" | ||
local back = " | local back = "oɔu" | ||
local vowels = "[a" .. front .. back .. " | local vowels = "[a" .. front .. back .. "ː´]" | ||
local function laxen(v) | local function laxen(v) | ||
Line 57: | Line 57: | ||
{"(" .. consonants .. ")(·?ˈ?)(" .. consonants .. ")", function(c1, st, c2) return same(c1,c2) and st .. c1 or c1 .. st .. c2 end}, | {"(" .. consonants .. ")(·?ˈ?)(" .. consonants .. ")", function(c1, st, c2) return same(c1,c2) and st .. c1 or c1 .. st .. c2 end}, | ||
{"jj", "j"}, {"(·" .. consonants .. ")e$", "%1ə"}, | {"jj", "j"}, {"(·" .. consonants .. ")e$", "%1ə"}, | ||
} | } | ||
Line 68: | Line 66: | ||
term = gsub(term, "·(" .. consonants .. ")·", "%1·") | term = gsub(term, "·(" .. consonants .. ")·", "%1·") | ||
local syll = split(term, "·"); local | local syll = split(term, "·"); local weight = {}; local st = ""; | ||
for i, syllable in ipairs(syllables) do | |||
if match( | if match(syllable, "´") then -- if the user inputted manual stress, ignore all the rest | ||
table.insert(syllables, i, "ˈ") | |||
return table.concat(syllables) | |||
end | |||
if match(syllable, "ː") then weight[i] = "sh" | |||
else | elseif match(syllable, "ŋ$") or match(syllable, "[aeiouɛɪɔʊ][aeiouɛɪɔʊ]") then weight[i] = "h" | ||
else weight[i] = "l" | |||
end | end | ||
if weight[i] == "sh" then | |||
table.insert(syllables, i, "ˈ") | |||
st = true | |||
end | |||
end | |||
if (#syllable ~= 1) and (not st) then | |||
local p, f = weight[#weight-1], weight[#weight] -- penultimate and final syllables | |||
if p == "l" and f == "h" then table.insert(syllables, #syllables, "ˈ") | |||
else table.insert(syllables, #syllables-1, "ˈ") end | |||
end | end | ||
return table.concat( | return table.concat(syllables, "·") | ||
end | end | ||