Module:rad-stem/templates: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
(Fixed issue with * interfering with ending regex)
No edit summary
Line 970: Line 970:
local function get_forms(stem, ending, regex1, regex2, regex3, regex4, regex5, regex6)
local function get_forms(stem, ending, regex1, regex2, regex3, regex4, regex5, regex6)
if mw.ustring.find(stem, "%*") then
stem = "*" .. mw.ustring.gsub(stem, "%*", "")
end
local temp = {}
local temp = {}
local post = ""
local post = ""
Line 997: Line 994:
if type(stem) == "table" then
if type(stem) == "table" then
for i, form in ipairs(stem) do
for i, form in ipairs(stem) do
if mw.ustring.find(form['word'], "%*") then
form['word'] = "*" .. mw.ustring.gsub(form['word'], "%*", "")
end
temp[i] = {['word'] = mw.ustring.gsub(form['word'] .. ending, regex1, regex2), ['note'] = form['note']}
temp[i] = {['word'] = mw.ustring.gsub(form['word'] .. ending, regex1, regex2), ['note'] = form['note']}
temp[i]['word'] = mw.ustring.gsub(temp[i]['word'], regex3, regex4)
temp[i]['word'] = mw.ustring.gsub(temp[i]['word'], regex3, regex4)
Line 1,012: Line 1,012:
temp = new_temp
temp = new_temp
elseif type(stem) == "string" then
elseif type(stem) == "string" then
if mw.ustring.find(stem, "%*") then
stem = "*" .. mw.ustring.gsub(stem, "%*", "")
end
temp = mw.ustring.gsub(stem .. ending, regex1, regex2)
temp = mw.ustring.gsub(stem .. ending, regex1, regex2)
temp = mw.ustring.gsub(temp, regex3, regex4)
temp = mw.ustring.gsub(temp, regex3, regex4)

Navigation menu