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
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.
local function miiLetterCode(part)
local num, letter = mw.ustring.match(part, '^(%d+)%s*[%-–—]%s*([A-Za-z])$')
if num and letter then
return num .. '-' .. mw.ustring.upper(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,
}
return junk[spaced] == true
end
local function isJunkIpwLabel(part)
local lower = mw.ustring.lower(mw.text.trim(part or ''))
if lower == 'csu' or lower == 'fh' or lower == 'fid' or lower == 'illness' then
return true
end
local compact = mw.ustring.gsub(lower, '%s+', '')
if compact == 'docteam' 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
if not isJunkIpwItalianLabel(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