Module:rad-IPA: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 1,900: Line 1,900:
IPA = mw.ustring.gsub(IPA, "^".. V_long_regex, "") -- delete long vowel
IPA = mw.ustring.gsub(IPA, "^".. V_long_regex, "") -- delete long vowel
IPA = mw.ustring.gsub(IPA, "^[" .. C_regex .. "]+", "") -- delete consonant cluster
IPA = mw.ustring.gsub(IPA, "^[" .. C_regex .. "]+", "") -- delete consonant cluster
if IPA == nil then return nil end
local IPA_rhymes = {}
local IPA_rhymes = {}


while true do
while #IPA > 0 do
if mw.ustring.find(IPA, "^".. V_long_regex .. "[" .. C_regex .. "]+" .. V_short_regex) or mw.ustring.find(IPA, "^".. V_long_regex .. "[" .. C_regex .. "]+[uyiɔœɛɤa][" .. C_regex .. "]*$") then
if mw.ustring.find(IPA, "^".. V_long_regex .. "[" .. C_regex .. "]+" .. V_short_regex) or mw.ustring.find(IPA, "^".. V_long_regex .. "[" .. C_regex .. "]+[uyiɔœɛɤa][" .. C_regex .. "]*$") then
table.insert(IPA_rhymes, IPA)
table.insert(IPA_rhymes, IPA)
IPA = mw.ustring.gsub(IPA, "^".. V_long_regex, "") -- delete long vowel
elseif mw.ustring.find(IPA, "^".. V_long_regex) then
-- skip long vowels followed by long vowels
IPA = mw.ustring.gsub(IPA, "^".. V_long_regex, "") -- delete long vowel
IPA = mw.ustring.gsub(IPA, "^".. V_long_regex, "") -- delete long vowel
elseif mw.ustring.find(IPA, "^[uyiɔœɛɤa][" .. C_regex .. "]*$") or mw.ustring.find(IPA, "^" .. V_long_regex .. "[" .. C_regex .. "]*$") then
elseif mw.ustring.find(IPA, "^[uyiɔœɛɤa][" .. C_regex .. "]*$") or mw.ustring.find(IPA, "^" .. V_long_regex .. "[" .. C_regex .. "]*$") then
Line 1,917: Line 1,912:
else
else
IPA = mw.ustring.gsub(IPA, "^" .. V_short_regex, "%1") -- delete short vowel
IPA = mw.ustring.gsub(IPA, "^" .. V_short_regex, "%1") -- delete short vowel
IPA = mw.ustring.gsub(IPA, "^".. V_long_regex, "") -- delete long vowel
IPA = mw.ustring.gsub(IPA, "^[" .. C_regex .. "]+", "") -- delete consonant cluster
IPA = mw.ustring.gsub(IPA, "^[" .. C_regex .. "]+", "") -- delete consonant cluster
end
end
end
end
return IPA_rhymes
if #IPA_rhymes > 0 then return IPA_rhymes
else return nil end
end
end