Module:fr-pron/temp
Appearance
- The following documentation is located at Module:fr-pron/temp/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
local export = {}
function export.show(frame, noschwa)
local word = type(frame) == "table" and frame.args[1] or frame
--splitting to consonants and vowels, so "rouassions" > "r|oua|ss|io|n|s"
word = mw.ustring.gsub(word, "([aeiouàéèêâîôûäëïöüœ]+)", "|%1|")
word = mw.ustring.gsub(word, "([^aeiouàéèêâîôûäëïöüœ])", "|%1|")
word = mw.ustring.gsub(word, "%|+", "|")
word = mw.ustring.gsub(word, "^%|", "")
word = mw.ustring.gsub(word, "%|$", "")
--other vowels and consonants
word = mw.ustring.gsub(word, "c%|h", "ch")
word = mw.ustring.gsub(word, "g%|n", "gn")
word = mw.ustring.gsub(word, "([^aeiouàéèêâîôûäëïöüœ])%|%1", "%1%1")
word = mw.ustring.gsub(word, "i%|l$", "|ill")
word = mw.ustring.gsub(word, "i%|ll%|", "|ill|")
word = mw.ustring.gsub(word, "g%|u", "gu|")
word = mw.ustring.gsub(word, "q%|u", "qu|")
word = mw.ustring.gsub(word, "gu%|ë", "g|u")
word = mw.ustring.gsub(word, "([aeou])%|y","%1i|y")
word = mw.ustring.gsub(word, "i([aeiouàéèêâîôûäëïöüœ])", "i|%1")
word = mw.ustring.gsub(word, "u([aeiouàéèêâîôûäëïöüœ])", "u|%1")
word = mw.ustring.gsub(word, "ou([aeiouàéèêâîôûäëïöüœ])", "ou|%1")
word = mw.ustring.gsub(word, "%|+", "|")
word = mw.ustring.gsub(word, "^%|", "")
word = mw.ustring.gsub(word, "%|$", "")
--nasal vowels
word = mw.ustring.gsub(word, "%|n", "n|")
word = mw.ustring.gsub(word, "n%|n", "|nn")
word = mw.ustring.gsub(word, "n%|([aeiouàéèêâîôûäëïöüœ]+)", "|n%1")
word = mw.ustring.gsub(word, "%|m", "m|")
word = mw.ustring.gsub(word, "m%|m", "|mm")
word = mw.ustring.gsub(word, "m%|([aeiouàéèêâîôûäëïöüœ]+)", "|m%1")
--exception
word = mw.ustring.gsub(word, "^femme", "famme")
word = mw.ustring.gsub(word, "prudemment", "prudamment")
word = mw.text.split(word, "|", true)
local result = {}
for i,val in ipairs(word) do
if val == "a" then
table.insert(result, "a")
elseif val == "à" then
table.insert(result, "a")
elseif val == "â" then
table.insert(result, "ɑ")
elseif val == "ai" then
table.insert(result, "ɛ")
elseif val == "aî" then
table.insert(result, "ɛ")
elseif val == "aï" then
table.insert(result, "a.i")
elseif val == "ain" then
table.insert(result, "ɛ̃")
elseif val == "an" then
table.insert(result, "ɑ̃")
elseif val == "au" then
table.insert(result, "o")
elseif val == "e" then
if i==#word then
if i==2 then table.insert(result, "ə") end
elseif i==#word-1 then
if mw.ustring.match(word[#word], "[bcfghjklpvwx]") then
table.insert(result, "ɛ")
elseif mw.ustring.match(word[#word], "[drtz]") then
table.insert(result, "e")
elseif word[#word] == "ch" then
table.insert(result, "ɛ")
elseif word[#word] == "qu" then
table.insert(result, "ɛ")
elseif word[#word] == "s" then
else
table.insert(result, "ɛ")
end
else
if mw.ustring.match(word[i+1],"([^aeiouàéèêâîôûäëïöüœ])%1") then
table.insert(result, "ɛ")
elseif mw.ustring.match(word[i+2],"[^aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "ɛ")
else
table.insert(result, "ə")
end
end
elseif val == "ê" then
table.insert(result, "ɛ")
elseif val == "é" then
table.insert(result, "e")
elseif val == "è" then
table.insert(result, "ɛ")
elseif val == "eau" then
table.insert(result, "o")
elseif val == "ei" then
if word[i+1] and mw.ustring.match(word[i+1],"([^aeiouàéèêâîôûäëïöüœ])%1") then
table.insert(result, "ɛ")
elseif word[i+2] and mw.ustring.match(word[i+2],"[^aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "ɛ")
else
table.insert(result, "e")
end
elseif val == "eï" then
table.insert(result, "e.i")
elseif val == "ein" then
table.insert(result, "ɛ̃")
elseif val == "en" then
table.insert(result, "ɑ̃")
elseif val == "eu" then
if word[i+1] and mw.ustring.match(word[i+1],"([^aeiouàéèêâîôûäëïöüœ])%1") then
table.insert(result, "œ")
elseif word[i+2] and mw.ustring.match(word[i+2],"[^aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "œ")
else
table.insert(result, "ø")
end
elseif val == "i" then
if word[i+1] and mw.ustring.match(word[i+1], "[aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "j")
else
table.insert(result, "i")
end
elseif val == "î" then
table.insert(result, "i")
elseif val == "in" then
table.insert(result, "ɛ̃")
elseif val == "o" then
if word[i+1] and mw.ustring.match(word[i+1],"([^aeiouàéèêâîôûäëïöüœ])%1") then
table.insert(result, "ɔ")
elseif word[i+2] and mw.ustring.match(word[i+2],"[^aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "ɔ")
else
table.insert(result, "o")
end
elseif val == "ô" then
table.insert(result, "o")
elseif val == "oë" then
table.insert(result, "ɔ.ɛ")
elseif val == "oeu" then
table.insert(result, "œ")
elseif val == "oi" then
table.insert(result, "wa")
elseif val == "oin" then
table.insert(result, "wɛ̃")
elseif val == "on" then
table.insert(result, "ɔ̃")
elseif val == "ou" then
if word[i+1] and mw.ustring.match(word[i+1], "[aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "w")
else
table.insert(result, "u")
end
elseif val == "u" then
if word[i+1] and mw.ustring.match(word[i+1], "[aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "ɰ")
else
table.insert(result, "y")
end
elseif val == "un" then
table.insert(result, "œ̃")
elseif val == "œ" then
table.insert(result, "e")
elseif val == "œu" then
table.insert(result, "œ")
elseif val == "b" then
if i~=#word then
if i==#word-1 and word[#word] == "[^aeiouàéèêâîôûäëïöüœ]" then
else
table.insert(result, "b")
end
end
elseif val == "c" then
if word[i+1] and mw.ustring.match(word[i+1],"^[ei]") then
table.insert(result, "s")
else
table.insert(result, "k")
end
elseif val == "cc" then
if word[i+1] and mw.ustring.match(word[i+1],"^[ei]") then
table.insert(result, "ks")
else
table.insert(result, "k")
end
elseif val == "ç" then
table.insert(result, "s")
elseif val == "d" then
if i~=#word then
if i==#word-1 and word[#word] == "[^aeiouàéèêâîôûäëïöüœ]" then
else
table.insert(result, "d")
end
end
elseif val == "dd" then
table.insert(result, "d")
elseif val == "ff" then
table.insert(result, "f")
elseif val == "g" then
if i~=#word then
if i==#word-1 and word[#word] == "[^aeiouàéèêâîôûäëïöüœ]" then
else
if word[i+1] and mw.ustring.match(word[i+1],"^[ei]") then
table.insert(result, "ʒ")
else
table.insert(result, "ɡ")
end
end
end
elseif val == "gg" then
if word[i+1] and mw.ustring.match(word[i+1],"^[ei]") then
table.insert(result, "ɡʒ")
else
table.insert(result, "ɡ")
end
elseif val == "gn" then
table.insert(result, "ɲ")
elseif val == "gu" then
table.insert(result, "ɡ")
elseif val == "h" then
elseif val == "j" then
table.insert(result, "ʒ")
elseif val == "kk" then
table.insert(result, "k")
elseif val == "ll" then
table.insert(result, "l")
elseif val == "ill" then
table.insert(result, "j")
elseif val == "mm" then
table.insert(result, "m")
elseif val == "nn" then
table.insert(result, "n")
elseif val == "p" then
if i~=#word then
if i==#word-1 and word[#word] == "[^aeiouàéèêâîôûäëïöüœ]" then
else
table.insert(result, "p")
end
end
elseif val == "pp" then
table.insert(result, "p")
elseif val == "qu" then
table.insert(result, "k")
elseif val == "r" then
table.insert(result, "ʁ")
elseif val == "rr" then
table.insert(result, "ʁ")
elseif val == "s" then
if i~=#word then
if word[i+1] and mw.ustring.match(word[i+1],"[aeiouàéèêâîôûäëïöüœ]") and word[i-1] and mw.ustring.match(word[i+1],"[aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "z")
else
table.insert(result, "s")
end
end
elseif val == "ss" then
table.insert(result, "s")
elseif val == "t" then
if i~=#word then
table.insert(result, "t")
end
elseif val == "tt" then
table.insert(result, "t")
elseif val == "vv" then
table.insert(result, "v")
elseif val == "x" then
if i~=#word then
table.insert(result, "ks")
end
elseif val == "y" then
if word[i+1] and mw.ustring.match(word[i+1],"[aeiouàéèêâîôûäëïöüœ]") then
table.insert(result, "j")
else
table.insert(result, "i")
end
else
table.insert(result, val)
end
end
return table.concat(result)
end
function export.noschwa(frame)
return export.show(frame, true)
end
return export