Module:rad-pronunciation: Difference between revisions

m
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
(Added automatic affix recognition to turn off rhyme display)
mNo edit summary
Line 48: Line 48:
local syllables = {}
local syllables = {}
local homophones = {}
local homophones = {}
local function insert_rhyme(input, pos)
local new_rhyme = m_rad_IPA.get_rhyme(input)
if not (new_rhyme == nil or table.contains(rhymes, new_rhyme)) then
if pos == nil then
table.insert(rhymes, new_rhyme)
else
table.insert(rhymes, pos, new_rhyme)
end
mw.log("Rhyme registered: " .. new_rhyme)
end
end
-- get data --
-- get data --
Line 74: Line 61:
if mw.ustring.find(word, "^[%-·]") or mw.ustring.find(word, "[%-·]$") then
if mw.ustring.find(word, "^[%-·]") or mw.ustring.find(word, "[%-·]$") then
show_rhymes = false
show_rhymes = false
end
local function insert_rhyme(input, pos)
local new_rhyme = m_rad_IPA.get_rhyme(input)
if not (new_rhyme == nil or table.contains(rhymes, new_rhyme)) and show_rhymes then
if pos == nil then
table.insert(rhymes, new_rhyme)
else
table.insert(rhymes, pos, new_rhyme)
end
mw.log("Rhyme registered: " .. new_rhyme)
end
end
end
Line 105: Line 104:
IPA_no_auto = true
IPA_no_auto = true
elseif args[i] ~= nil then
elseif args[i] ~= nil then
table.insert(IPA[mode_dialect][mode_register], args[i])
local temp_arg = args[i]
mw.log("IPA: added '" .. args[i] .. "' to IPA[" .. mode_dialect .. "][" .. mode_register .. "]")
if not mw.ustring.find(temp_arg, "%/(.*)%/") then
if mw.ustring.find(temp_arg, "%[(.*)%]") then
temp_arg = "/" .. mw.ustring.match(temp_arg, "(.*) %[") .. "/ " .. mw.ustring.match(temp_arg, "(%[.*%])")
else
temp_arg = "/" .. temp_arg .. "/ "
end
end
table.insert(IPA[mode_dialect][mode_register], temp_arg)
mw.log("IPA: added '" .. temp_arg .. "' to IPA[" .. mode_dialect .. "][" .. mode_register .. "]")
if mode_dialect == "standard" or mode_dialect == "hjádvanþs" then
if mode_dialect == "standard" or mode_dialect == "hjádvanþs" then
local just_phonemic = mw.ustring.match(args[i], "%/(.*)%/")
local just_phonemic = mw.ustring.match(temp_arg, "%/(.*)%/")
insert_rhyme(just_phonemic)
insert_rhyme(just_phonemic)
end
end