Module:av-pron: Difference between revisions

1,057 bytes removed ,  8 November 2019
no edit summary
(Created page with "local export = {} if type(word) == 'table' then do_debug = word.args[4] word = word.args[1] end local orig_word = word word = mw.ustring.lower(word or mw.title.getCu...")
 
No edit summary
Line 13: Line 13:
local V = "[aeiou]" -- vowel
local V = "[aeiou]" -- vowel
local C = "[^aeiou.]" -- consonant
local C = "[^aeiou.]" -- consonant
--determining whether "y" is a consonant or a vowel + diphthongs, "-mente" suffix
word = mw.ustring.gsub(word, "y(" .. C .. ")", "i%1")
word = mw.ustring.gsub(word, "y(" .. V .. ")", "ɟ%1") -- not the real sound
word = mw.ustring.gsub(word, "hi(" .. V .. ")", "ɟ%1")
word = mw.ustring.gsub(word, "y$", "ï")
    word = mw.ustring.gsub(word, "mente$", "ménte")
--"c" & "g" before "i" and "e" and all that stuff
--"c" & "g" before "i" and "e" and all that stuff
Line 74: Line 68:
word = mw.ustring.gsub(word, "([pbktdɡ])%.([lɾ])", ".%1%2")
word = mw.ustring.gsub(word, "([pbktdɡ])%.([lɾ])", ".%1%2")
word = mw.ustring.gsub(word, "(" .. C .. ")%.s(" .. C .. ")", "%1s.%2")
word = mw.ustring.gsub(word, "(" .. C .. ")%.s(" .. C .. ")", "%1s.%2")
word = mw.ustring.gsub(word, "([aeoáéíóú])([aeoáéíóú])", "%1.%2")
word = mw.ustring.gsub(word, "([aeo])([aeo])", "%1.%2")
word = mw.ustring.gsub(word, "([])([])", "%1.%2")
word = mw.ustring.gsub(word, "([i])([i])", "%1.%2")
word = mw.ustring.gsub(word, "([])([])", "%1.%2")
word = mw.ustring.gsub(word, "([u])([u])", "%1.%2")
 
table.insert(debug, word)
--diphthongs
word = mw.ustring.gsub(word, 'ih?([aeouáéóú])', 'j%1')
word = mw.ustring.gsub(word, 'uh?([aeioáéíó])', 'w%1')
table.insert(debug, word)
--accentuation
local syllables = mw.text.split(word, "%.")
if mw.ustring.find(word, "[áéíóú]") then
for i = 1, #syllables do
if mw.ustring.find(syllables[i], "[áéíóú]") then
syllables[i] = "ˈ"..syllables[i]
end
end
else
if mw.ustring.find(word, "[^aeiouns]$") then
syllables[#syllables] = "ˈ" .. syllables[#syllables]
else
if #syllables > 1 then
syllables[#syllables-1] = "ˈ" .. syllables[#syllables-1]
end
end
end


table.insert(debug, word)
table.insert(debug, word)