local p = local getArgs = require('Module:Arguments').getArgslocal gsub = mw.ustring.gsub
local function isCons(s) if s
'd' or s
'dʒ' or s
'f' or s
'h' or s
'j' or s
'l' or s
'm' or s
'nj' or s
'p' or s
's' or s
'ʃ' or s
'tj' or s
'θ' or s
'v' or s
'z' or s
'ʒ' or s
'ʔ' then return true endend
local function isVowel(s) if s
'ɑːr' or s
'ɒr' or s
'ær' or s
'aɪər' or s
'aʊər' or s
'ɛr' or s
'ɛər' or s
'ɪr' or s
'ɪər' or s
'ɔːr' or s
'ɔɪər' or s
'ɔər' or s
'ʊr' or s
'ʊər' or s
'jʊər' or s
'ʌr' or s
'ə' or s
'əl' or s
'əm' or s
'u' or s
'ᵿ' or s
local function isChecked(s) if s
'æ' or s
'ɪ' or s
'ʌ' then return true endend
local function isSeg(s) if isCons(s) or isVowel(s) then return true endend
local function isStr(s) if s
'ˌ' then return true endend
local function toResp(s) if s
'dʒ' then return 'j' elseif s
'ɡ' then return 'g' elseif s
'j' then return 'y' elseif s
'nj' then return 'ny' elseif s
'sj' then return 'sy' elseif s
'tj' then return 'ty' elseif s
'θ' then return 'th' elseif s
'zj' then return 'zy' elseif s
'ɑː' then return 'ah' elseif s
'ɒ' then return 'o' elseif s
'æ' then return 'a' elseif s
'aɪ' then return 'eye' elseif s
'aʊ' then return 'ow' elseif s
'ɛ' then return 'e' elseif s
'eɪ' then return 'ay' elseif s
'ɪ' then return 'i' elseif s
'iː' then return 'ee' elseif s
'ɔː' then return 'aw' elseif s
'ɔɪ' then return 'oy' elseif s
'oʊ' then return 'oh' elseif s
'ʊ' then return 'uu' elseif s
'uː' then return 'oo' elseif s
'juː' then return 'ew' elseif s
'ʌ' then return 'u' elseif s
'ɜːr' then return 'ur' elseif s
'u' then return 'oo' elseif s
'ᵿ' then return 'uu' elseif s
'x' then return 'kh' else return s endend
function p._main(args) local ret = local strNum = local hasPrimStress = false for i, v in ipairs(args) do -- Swap stress and consonant after checked vowel if isChecked(args[i - 2]) and isStr(args[i - 1]) and isCons(v) then args[i] = args[i - 1] args[i - 1] = v end -- Disable secondary stress following primary stress if v
'_' or v
'ˌ' then args[i] = '.' end end for i, v in ipairs(args) do if v
-- Break after checked vowel + segment if isChecked(args[i - 1]) and isSeg(v) and isSeg(args[i + 1]) then -- See if there's a vowel down the line local j = i + 1 while args[j] do if isVowel(args[j]) then j = isVowel(args[j]) break end j = j + 1 end if j
function p.main(frame) local args = getArgs(frame) return frame:expandTemplate .. ' ' ..-- p._main(args)end
return p