local export = {}
function export.show(word,Southern,phonetic,do_debug)
local debug = {}
if type(word) == 'table' then
do_debug = word.args
word = word.args
end
word = (word or mw.title.getCurrentTitle().text):lower()
word = mw.ustring.gsub(word,"","")
table.insert(debug,word)
--alphabet-to-phoneme (native sounds)
word = mw.ustring.gsub(word,"e","ɛ")
word = mw.ustring.gsub(word,"g","ɡ")
word = mw.ustring.gsub(word,"r","ɾ")
word = mw.ustring.gsub(word,"y","ɟ") --not the real sound
--native digraphs and trigraphs
word = mw.ustring.gsub(word,"()ng(?)","%1ŋ%2")
word = mw.ustring.gsub(word,"()ngg()","%1%ŋɡ%2")
word = mw.ustring.gsub(word,"kuw()","kw%1")
word = mw.ustring.gsub(word,"()sy()","%1ʃ%2")
word = mw.ustring.gsub(word,"dy","dj")
word = mw.ustring.gsub(word,"ty","tj")
word = mw.ustring.gsub(word,"()ny()","%1ñ%2") --not the real sound
--alphabet-to-phoneme (for assimilated Spanish forms)
word = mw.ustring.gsub(word,"qu","k")
word = mw.ustring.gsub(word,"v","b")
word = mw.ustring.gsub(word,"(?)ch()","%1ts%2")
word = mw.ustring.gsub(word,"()ll()","%1ʎ%2")
word = mw.ustring.gsub(word,'',{='k', ='p', ='h', ='ɲ', ='r', ='h', ='s'}) --='ɡ': U+0067 LATIN SMALL LETTER G → U+0261 LATIN SMALL LETTER SCRIPT G
table.insert(debug,word)
--"c" & "g" before "i" and "e" (proper nouns from Spanish, such as place names, given names, and surnames, or Spanish transcriptions of native words only)
word = mw.ustring.gsub(word,"()c()","%1s%2")
word = mw.ustring.gsub(word,"()gü()","%1ɡw%2")
word = mw.ustring.gsub(word,"ü","w")
word = mw.ustring.gsub(word,"(?)gu()","%1ɡ%2")
--"cu" before any vowel (proper nouns from Spanish, such as place names, given names, and surnames, or Spanish transcriptions of native words only)
word = mw.ustring.gsub(word,"cu()",('kw') .. "%1")
table.insert(debug,word)
--syllable division
word = mw.ustring.gsub(word,"()()()","%1.%2%3")
word = mw.ustring.gsub(word,"()()()","%1.%2%3")
word = mw.ustring.gsub(word,"()()()()","%1%2.%3%4")
word = mw.ustring.gsub(word,"()()()()","%1%2.%3%4")
word = mw.ustring.gsub(word,"()()()()()","%1%2.%3%4%5")
word = mw.ustring.gsub(word,"()()()()()","%1%2.%3%4%5")
word = mw.ustring.gsub(word,"()%.()",".%1%2")
word = mw.ustring.gsub(word,"()%.s()","%1s.%2")
word = mw.ustring.gsub(word,"()()","%1.%2")
word = mw.ustring.gsub(word,"()()","%1.%2")
word = mw.ustring.gsub(word,"()()","%1.%2")
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,"") then syllables = "ˈ"..syllables end
end
else
if mw.ustring.find(word,"$") then
syllables = "ˈ"..syllables
else
if #syllables > 1 then syllables = "ˈ"..syllables end
end
end
table.insert(debug,word)
--glottalization
local syllables = mw.text.split(word,"%.")
if mw.ustring.find(word,"") then
for i=1,#syllables do
for u=1,#syllables do
if mw.ustring.find(syllables,"",syllables) then syllables = "ˈ" syllables = "ʔ" end
end
end
else
local syllables = mw.text.split(word,"%.")
if mw.ustring.find(word,"") then
for i=1,#syllables do
if mw.ustring.find("",syllables) then syllables = "ʔ"..syllables end
end
end
--Closed syllables (in southern dialects, i.e. Batangas and Quezon)
local syllables = mw.text.split(word,"%.")
if mw.ustring.find(word,"") then
for i=1,#syllables do
if mw.ustring.find(syllables,"") then syllables = "ʔ"..syllables end
end
end
--removal of acute accent
for i=1,#syllables do
syllables = mw.ustring.gsub(syllables,'',{='a', ='e', ='i', ='o', ='u'})
end
--secondary stress
word = mw.ustring.gsub(word,'ˈ(.+)ˈ','ˌ%1ˈ')
word = mw.ustring.gsub(word,'ˈ(.+)ˌ','ˌ%1ˌ')
word = mw.ustring.gsub(word,'ˌ(.+)ˈ(.+)ˈ','ˌ%1ˌ%2ˈ')
--phonetic transcription
if phonetic then
--allophones
word = mw.ustring.gsub(word,'(?)j','d͡ʒ')
word = mw.ustring.gsub(word,'(?)j','ʃ')
word = mw.ustring.gsub(word,'(?)j','t͡ʃ')
word = mw.ustring.gsub(word,'(?)s()','%1t͡ʃ%2')
word = mw.ustring.gsub(word,'',{='r', ='ni'})
word = mw.ustring.gsub(word,'(?)ʃ()','s')
word = mw.ustring.gsub(word,'(?)k','%1x')
word = mw.ustring.gsub(word,'k()','kx%1')
end
--real sound of "ɟ"
word = mw.ustring.gsub(word,"ɟ","j")
word = mw.ustring.gsub(word,"ʎ","lj")
if do_debug == 'yes' then
return word .. table.concat(debug,"")
else
return word
end
end
end
function export.Southern(frame)
return export.show(frame,true)
end
function export.phonetic(frame)
return export.show(frame,false,true)
end
function export.phoneticSouthern(frame)
return export.show(frame,true,true)
end
return export