Module:rad-IPA: Difference between revisions

Added weak rhyme
m (Beautified)
(Added weak rhyme)
Line 1,884: Line 1,884:
     end
     end
     return IPA
     return IPA
end
function export.get_weak_rhyme(IPA)
if mw.ustring.find(IPA, "([ %|])") or mw.ustring.find(IPA, "ˈ") == nil then
        return nil
end
mw.log(IPA)
IPA = mw.ustring.match(IPA, "[^ˈˌ]+$")
mw.log(IPA)
IPA = mw.ustring.gsub(IPA, "^[szlntdrmpbθðhjwçfvʃʒxŋkɡɲ%.]+", "") -- delete consonant cluster
mw.log(IPA)
IPA = mw.ustring.gsub(IPA, "^[uyiɔœɛoɤeaæø][uyiɔœɛoɤeaæøː][ːeoi]?", "") -- delete long vowel
mw.log(IPA)
IPA = mw.ustring.gsub(IPA, "^[uyiɔœɛɤa]([^ːaeoiu])", "%1") -- delete short vowel
mw.log(IPA)
IPA = mw.ustring.gsub(IPA, "^[szlntdrmpbθðhjwçfvʃʒxŋkɡɲ%.]+", "") -- delete consonant cluster
mw.log(IPA)
while true do
if mw.ustring.find(IPA, "^[uyiɔœɛoɤeaæø][uyiɔœɛoɤeaæøː][ːeoi]?") or mw.ustring.find(IPA, "^[uyiɔœɛɤa][szlntdrmpbθðhjwçfvʃʒxŋkɡɲ%.]*$") then
break
else
IPA = mw.ustring.gsub(IPA, "^[uyiɔœɛɤa]([^ːaeoiu])", "%1") -- delete short vowel
mw.log(IPA)
IPA = mw.ustring.gsub(IPA, "^[szlntdrmpbθðhjwçfvʃʒxŋkɡɲ%.]+", "") -- delete consonant cluster
mw.log(IPA)
end
end
return IPA
end
end