Skip bogus IPW and IPW Italian labels
Fix 5th class exact-string map to Italian 5
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
-- IPW roster codes: 148T -> 148, 178? -> 178.
-- IPW roster codes: 148T -> 148, 178? -> 178.
-- Skip "14th Armd" / "2nd Armd". Lettered codes like 424-G are MII, not IPW.
-- Skip "14th Armd" / "2nd Armd". Lettered codes like 424-G are MII, not IPW.
-- 540-R / 545-R / 546-R categorize as unlettered MII 540/545/546.
local function miiLetterCode(part)
local function miiLetterCode(part)
local num, letter = mw.ustring.match(part, '^(%d+)%s*[%-–—]%s*([A-Za-z])$')
local num, letter = mw.ustring.match(part, '^(%d+)%s*[%-–—]%s*([A-Za-z])$')
if num and letter then
if num and letter then
return num .. '-' .. mw.ustring.upper(letter)
letter = mw.ustring.upper(letter)
if letter == 'R' and (num == '540' or num == '545' or num == '546') then
return num
end
return num .. '-' .. letter
end
end
return nil
return nil
Line 23: Line 28:
}
}
return junk[spaced] == true
return junk[spaced] == true
end
local function normalizeIpwItalianCode(part)
part = mw.text.trim(part or '')
if part == '' or isJunkIpwItalianLabel(part) then
return nil
end
local spaced = mw.ustring.lower(mw.ustring.gsub(part, '%s+', ' '))
if spaced == '5th class' or spaced == 'italian 5th class' then
return '5'
end
return part
end
end


Line 93: Line 110:
table.insert(out, '[[Category:Team MII ' .. mii .. ']]')
table.insert(out, '[[Category:Team MII ' .. mii .. ']]')
elseif prefix == 'Team IPW Italian ' then
elseif prefix == 'Team IPW Italian ' then
if not isJunkIpwItalianLabel(part) then
part = normalizeIpwItalianCode(part)
if part then
table.insert(out, '[[Category:' .. prefix .. part .. ']]')
table.insert(out, '[[Category:' .. prefix .. part .. ']]')
end
end