Soft launch: Soldier biographies and research notes vary in completeness. Prefer class-roster, NARA, newspapers, and other cited sources for contested facts — treat Research notes as leads, not settled history. Anyone can correct a page; contact us with questions.
Module:SplitCats: Difference between revisions
Jump to navigation
Jump to search
Map Italian 5th class to Team IPW Italian 5 |
Italian 5th class -> 5; MII 540-R -> 540 |
||
| 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 .. '-' .. | 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 | ||
Revision as of 04:10, 19 August 2026
Documentation for this module may be created at Module:SplitCats/doc
local p = {}
-- IPW roster codes: 148T -> 148, 178? -> 178.
-- 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 num, letter = mw.ustring.match(part, '^(%d+)%s*[%-–—]%s*([A-Za-z])$')
if num and letter then
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
return nil
end
local function isJunkIpwItalianLabel(part)
local lower = mw.ustring.lower(mw.text.trim(part or ''))
local spaced = mw.ustring.gsub(lower, '%s+', ' ')
local junk = {
['16063'] = true, ['16095'] = true, ['16302'] = true,
['16320'] = true, ['16695'] = true,
['1st army'] = true, ['2 day'] = true, ['2/23/44'] = true,
['468th cic'] = true, ['5/7/45'] = true, ['8/24/44'] = true, ['8/7/43'] = true,
['apid'] = true, ['i-32'] = true, ['mis-eto'] = true, ['mitc'] = true,
['pac'] = true, ['sc7'] = true, ['shaef'] = true, ['v-831'] = 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 mw.ustring.match(spaced, '^(italian )?5th class$') then
return '5'
end
return part
end
local function isJunkIpwLabel(part)
local lower = mw.ustring.lower(mw.text.trim(part or ''))
lower = mw.ustring.gsub(lower, '%s+', ' ')
lower = mw.ustring.gsub(lower, '%s*%?+%s*$', '')
lower = mw.text.trim(lower)
if lower == 'csu' or lower == 'fh' or lower == 'fid' or lower == 'illness'
or lower == 'mfiu-5' or lower == 'mfiu 5' or lower == 'mitu 5' or lower == 'mitu-5'
or lower == 'mrbc4' or lower == 'mrbc 4' or lower == 't force' or lower == 'to cic' then
return true
end
local compact = mw.ustring.gsub(lower, '[%s%-]+', '')
if compact == 'docteam' or compact == 'mfiu5' or compact == 'mitu5'
or compact == 'mrbc4' or compact == 'tforce' or compact == 'tocic' then
return true
end
return false
end
local function normalizeIpwCode(part)
part = mw.text.trim(part or '')
if part == '' then
return nil
end
part = mw.ustring.gsub(part, '%s*%?+%s*$', '')
part = mw.text.trim(part)
if part == '' then
return nil
end
local lower = mw.ustring.lower(part)
if mw.ustring.find(lower, 'armd', 1, true) or mw.ustring.find(lower, 'armored', 1, true) then
return nil
end
if miiLetterCode(part) then
return nil
end
if isJunkIpwLabel(part) then
return nil
end
local num = mw.ustring.match(part, '^(%d+)[Tt]$')
if num then
return num
end
if mw.ustring.match(lower, '^%d+(st|nd|rd|th)$') then
return nil
end
if mw.ustring.match(part, '^%d+$') then
return part
end
if isJunkIpwLabel(part) then
return nil
end
return part
end
function p.categories(frame)
local raw = frame.args[1] or ''
local prefix = frame.args[2] or 'Class '
raw = mw.ustring.gsub(raw, ';', ';')
local isIpw = mw.ustring.find(prefix, 'Team IPW', 1, true) == 1
local out = {}
for part in mw.text.gsplit(raw, ';', true) do
part = mw.text.trim(part)
if part ~= '' and not mw.ustring.find(part, ';', 1, true) then
if isIpw then
local mii = miiLetterCode(part)
if mii then
table.insert(out, '[[Category:Team MII ' .. mii .. ']]')
elseif prefix == 'Team IPW Italian ' then
part = normalizeIpwItalianCode(part)
if part then
table.insert(out, '[[Category:' .. prefix .. part .. ']]')
end
else
part = normalizeIpwCode(part)
if part then
table.insert(out, '[[Category:' .. prefix .. part .. ']]')
end
end
else
table.insert(out, '[[Category:' .. prefix .. part .. ']]')
end
end
end
return table.concat(out)
end
function p.letterCategory(frame)
local title = mw.title.getCurrentTitle()
local first = mw.ustring.upper(mw.ustring.sub(title.text, 1, 1))
if mw.ustring.match(first, '[A-Z]') then
return '[[Category:Soldiers ' .. first .. ']]'
end
return '[[Category:Soldiers other]]'
end
return p