local export = {}
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("mdf")
local letters_phonemes = {
= "ɑ", = "ɑː",
= "e", = "eː",
= "i", = "iː",
= "o", = "oː",
= "u", = "uː",
= "ɤ", = "ɤː",
= "æ", = "æː",
= "ø", = "øː",
= "y", = "yː",
= "ə",
= "ə",
= "ɤɑ̯",
= "øɑ̯",
= "yɑ̯",
= "ɑ",
= "oe̯",
= "ɤe̯",
= "æe̯",
= "øe̯",
= "ɑi̯",
= "ei̯",
= "oi̯",
= "ui̯",
= "ɤi̯",
= "æi̯",
= "øi̯",
= "yi̯",
= "ɑo̯",
= "eo̯",
= "uo̯",
= "ɤo̯",
= "æo̯",
= "ɑu̯",
= "iu̯",
= "ou̯",
= "ɤu̯",
= "æu̯",
= "bʲ",
= "b",
= "ŋ",
= "ç",
= "t͡sʲ",
= "l̥",
= "ɡʲ",
= "b",
= "zʲ",
= "b",
= "d",
= "dʲ",
= "ɡ",
= "p", = "pʲ",
= "t",
= "tʲ",
= "k", = "kʲ",
= "f",
= "h",
= "s",
= "sʲ",
= "l",
= "lʲ",
= "r", = "rʲ",
= "m", = "mʲ",
= "n",
= "nʲ", = "nʲː",
= "j",
= "v", = "vʲ",
= "ʃ",
= "ʒ",
= "t͡s",
= "t͡ʃ",
= "ʃʲ",
= "t͡ʃʲ",
= "ˈ",
}
local function IPA_word(word)
-- Make everything lowercase so we don't have to deal with case differences
word = mw.ustring.lower(word)
local rest = word
local phonemes = {}
while mw.ustring.len(rest) > 0 do
-- Find the longest string of letters that matches a recognised sequence in the list
local longestmatch = ""
for letter, phoneme in pairs(letters_phonemes) do
if mw.ustring.sub(rest, 1, mw.ustring.len(letter)) == letter and mw.ustring.len(letter) > mw.ustring.len(longestmatch) then
longestmatch = letter
end
end
-- Convert the string to IPA
if mw.ustring.len(longestmatch) > 0 then
table.insert(phonemes, letters_phonemes)
rest = mw.ustring.sub(rest, mw.ustring.len(longestmatch) + 1)
else
-- If no match was found, just insert the character as it is
table.insert(phonemes, mw.ustring.sub(rest, 1, 1))
rest = mw.ustring.sub(rest, 2)
end
end
local ipa = table.concat(phonemes)
-- Add default stress mark is one is not already present
if not mw.ustring.find(ipa, "ˈ") then
ipa = "ˈ" .. ipa
end
return ipa
end
function export.IPA(frame)
local words = {}
for _, word in ipairs(frame:getParent().args) do
table.insert(words, word)
end
if #words == 0 then
words = {mw.title.getCurrentTitle().text}
end
for key, word in ipairs(words) do
words = IPA_word(word)
end
return m_IPA.format_IPA_full { lang = lang, items = {{pron = "/" .. table.concat(words) .. "/"}} }
end
return export