3 of 2 tests failed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
![]() | inán<F> | inǽn | ʔɪnɑ́n<f> |
![]() | ínan<F> | ínæn | ʔɪ́nɑn<f> |
Script error during testing: Module:User:AmazingJus/so:56: Entry does not have a tone mark.stack traceback: : ? : in function 'error' Module:User:AmazingJus/so:56: in function 'toIPA' Module:User:AmazingJus/so/testcases:11: in function 'func' Module:UnitTests:313: in function 'iterate' Module:User:AmazingJus/so/testcases:23: in function <Module:User:AmazingJus/so/testcases:17> (tail call): ? (tail call): ? : in function 'xpcall' Module:fun/xpcall:37: in function 'xpcall' Module:UnitTests:389: in function <Module:UnitTests:350> (tail call): ? mw.lua:527: in function <mw.lua:507> : ? : in function 'expandTemplate' mw.lua:333: in function <mw.lua:307> (tail call): ? (tail call): ? Module:documentation:1043: in function 'chunk' mw.lua:527: in function <mw.lua:507> : ? |
local export = {}
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("so")
local sc = require("Module:scripts").getByCode("Latn")
local hyphen = require("Module:hyphenation")
local table = require("Module:table")
function export.tag_text(text, face)
return require("Module:script utilities").tag_text(text, lang, sc, face)
end
function export.link(term, face)
return require("Module:links").full_link( { term = term, lang = lang, sc = sc }, face )
end
local U = mw.ustring.char
local decomp = mw.ustring.toNFD
local find = mw.ustring.find
local gsub = mw.ustring.gsub
local lower = mw.ustring.lower
local strip = mw.text.trim
local acute = U(0x301)
local grave = U(0x300)
local circumflex = U(0x302)
local semibreve = U(0x32F)
local tones = ""
local cons = {
= "d͡ʒ", = "ħ", = "ħ", = "ʃ", = "ɖ",
= "ʕ", = "ɡ", = "j", = "ʔ"
}
-- order of vowels: front, back
local vowels = {
= { "æ", "ɑ" },
= { "e", "ɛ" },
= { "i", "ɪ" },
= { "ɵ", "ɔ" },
= { "ʉ", "u" }
}
function export.toIPA(term, front)
if type(term) == "table" then
term = term.args
end
-- make all term lowercase and word borders have a space
term = lower(term)
term = " " .. term .. " "
-- decompose tone accents where entries must have tones marked
term = decomp(term)
if not find(term, tones) then
error("Entry does not have a tone mark.")
end
term = gsub(term, "()w(?)(w?)", "%1u" .. semibreve .. "%2%3")
term = gsub(term, "()y(?)(y?)", "%1i" .. semibreve .. "%2%3")
term = gsub(term, "()%1(h?)", "%1%2ː")
term = gsub(term, " ()", " ʔ%1")
-- assign consonant values
term = gsub(term, "h?", cons)
-- assign appropriate values for vowels
if front then
term = gsub(term, "", function(vowel)
return vowels
end)
else
term = gsub(term, "", function(vowel)
return vowels
end)
end
-- grave accent is falling tone
term = gsub(term, grave, circumflex)
return strip(term)
end
return export