5 753
contributi
Modifiche
nessun oggetto della modifica
local long = "ː"
local acute_or_grave = "[" .. mw.ustring.char(0x300, 0x301) .. "]"
local vowels = "aeɛioɔuæaeɛioɔu"
local vowel = "[" .. vowels .. "]"
local not_vowel = "[^" .. vowels .. "]"
function export.to_phonemic(word, voiced_z, single_character_affricates)
word = mw.ustring.lower(word)
if mw.ustring.find(word,"sč") then word = mw.ustring.toNFC(word) --sč at the end of a word is /ʃ/ word = word:gsub("sč","ʃ") end if mw.ustring.find(word,"č") then word = mw.ustring.toNFC(word) --sč at the end of a word is /ʧ/ word = word:gsub("č","ʧ") end if mw.ustring.find(word,"â") then word = mw.ustring.toNFC(word) -- â at the end of a word is /æ/ word = word:gsub("â","æ") end if mw.ustring.find(word,"ğ") then word = mw.ustring.toNFC(word) --ğ at the end of a word is /ʤ/ word = word:gsub("ğ","ʤ") end
-- Decompose combining characters: for instance, è → e + ◌̀
local decomposed = mw.ustring.toNFD(word)
end
-- Transcriptions must contain an acute or grave, to indicate stress position.
-- This does not handle phrases containing more than one stressed word.
-- Default to penultimate stress rather than throw error?
if not mw.ustring.find(decomposed, acute_or_grave) then -- Allow monosyllabic unstressed words. --local vowel_count = select(2, decomposed:gsub("[aeiouæaeiou]", "%1")) --if vowel_count ~= 1 then transcriptio=mw.ustring.sub(decomposed,-1) if transcriptio == 'a' then decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2") - Add acute accent on second-to-last end elseif transcriptio =='e' then decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel.. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2") elseif transcriptio =='o' then decomposed = mw.ustring.gsub(decomposed, "(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .."*)$","%1" .. mw.ustring.char(0x301) .. "%2") elseif transcriptio =='i' then decomposed = mw.ustring.gsub(decomposed,"(" .. vowel .. ")(" .. not_vowel .. "*" .. vowel .. not_vowel .. "*)$", "%1" .. mw.ustring.char(0x301) .. "%2") else decomposed=mw.ustring.gsub(decomposed,"(".. vowel ..")(" .. not_vowel .. "*)$",'%1' ..mw.ustring.char(0x301).. '%2') end end
local transcription = decomposed
return ({ e = "ɛ", o = "ɔ" })[vowel] .. accent
end) -- e or o followed by grave
-- ci, gi + vowel
-- Do ci, gi + e, é, è sometimes contain /j/?
end)
end
-- Handle other cases of c, g.
transcription = mw.ustring.gsub(transcription,
"(([cg])([cg]?)(h?))(.?))",
function (consonant, first, double, second, next)
-- Don't allow the combinations cg, gc.
local consonant
if (next == "e" or next == "ɛ" or next == "i") and second ~= "h" then
if first == "'c" ' then
consonant = "ʧ"
else
end -- else return s
end)
-- n a fine parola ha diversa pronuncia transcriptio=mw.ustring.sub(transcription,-1) if transcriptio=='n' then transcription=transcription..' ' transcription=mw.ustring.gsub(transcription,'n ','ŋ') end
-- After a vowel, /ʃ ʎ ɲ/ are doubled.
-- [[w:Italian phonology]] says word-internally, [[w:Help:IPA/Italian]] says
"([kg])(" .. front .. ")",
"%1" .. fronted .. "%2")
:gsub("a", "äa")
:gsub("n", "n̺") -- Converts n before a consonant, which is incorrect.
end
local transcription = "/[" .. export.to_phonemicto_phonetic(word, voiced_z) .. "/]"
return m_IPA.format_IPA_full(