Module:Infobox television disambiguation check
From Phuketer
Documentation for this module may be created at Module:Infobox television disambiguation check/doc
require("strict")
local getArgs = require("Module:Arguments").getArgs
local validateDisambiguation = require("Module:Television infoboxes disambiguation check")
local p = {}
-----------------------------------------------------------------------
-- Valid disambiguation types for infobox television
-----------------------------------------------------------------------
local validDisambiguationTypeList = {
"TV series",
"TV programme",
"TV program",
"TV film",
"film",
"miniseries",
"serial",
"game show",
"talk show",
"web series"
}
-----------------------------------------------------------------------
-- Valid disambiguation patterns (AFTER removing type)
-----------------------------------------------------------------------
local validDisambiguationPatternList = {
-- YEAR + COUNTRY → "1999 American"
validateDisambiguation.DisambiguationPattern{
pattern = "^(%d+)%s+(%D+)$",
type = validateDisambiguation.VALIDATION_TYPE_YEAR_COUNTRY
},
-- YEAR ONLY → "1999"
validateDisambiguation.DisambiguationPattern{
pattern = "^%d+$",
type = validateDisambiguation.VALIDATION_TYPE_YEAR
},
-- COUNTRY ONLY → "American"
validateDisambiguation.DisambiguationPattern{
pattern = "^%D+$",
type = validateDisambiguation.VALIDATION_TYPE_COUNTRY
}
}
-----------------------------------------------------------------------
-- Titles where parentheses are NOT disambiguation
-----------------------------------------------------------------------
local exceptionList = {
"The (206)",
"Bigg Boss (Hindi TV series)",
"Bigg Boss (Malayalam TV series)",
"Bigg Boss (Tamil TV series)",
"Bigg Boss (Telugu TV series)",
"Cinderella (Apakah Cinta Hanyalah Mimpi?)",
"Deal or No Deal Malaysia (English-language game show)",
"Deal or No Deal Malaysia (Mandarin-language game show)",
"Gympl s (r)učením omezeným",
"How to Live with Your Parents (For the Rest of Your Life)",
"How to Sell Drugs Online (Fast)",
"I (Almost) Got Away With It",
"I Do (But I Don't)",
"Kevin (Probably) Saves the World",
"Love (ft. Marriage and Divorce)",
"M.R.S. (Most Requested Show)",
"Monty Python: Almost the Truth (Lawyers Cut)",
"Off Sides (Pigs vs. Freaks)",
"Randall and Hopkirk (Deceased)",
"Wednesday 9:30 (8:30 Central)",
"Who the (Bleep)...",
"Who the (Bleep) Did I Marry?"
}
-----------------------------------------------------------------------
-- Infoboxes that should NOT use this module
-----------------------------------------------------------------------
local otherInfoboxList = {
["franchise"] = "[[Category:Television articles using incorrect infobox|FRANCHISE]]",
["radio"] = "[[Category:Television articles using incorrect infobox|R]]",
["season"] = "[[Category:Television articles using incorrect infobox|S]]",
["series %d*"] = "[[Category:Television articles using incorrect infobox|S]]",
["TV programming block"] = "[[Category:Television articles using incorrect infobox|P]]",
["film series"] = "[[Category:Television articles using incorrect infobox|FILM]]"
}
-----------------------------------------------------------------------
-- No invalid title styles for this module
-----------------------------------------------------------------------
local invalidTitleStyleList = {}
-----------------------------------------------------------------------
-- Internal main
-----------------------------------------------------------------------
local function _main(args)
local title = args[1]
return validateDisambiguation.main(
title,
"infobox television",
validDisambiguationTypeList,
validDisambiguationPatternList,
exceptionList,
otherInfoboxList,
invalidTitleStyleList
)
end
-----------------------------------------------------------------------
-- Public entry point
-----------------------------------------------------------------------
function p.main(frame)
local args = getArgs(frame)
local category = _main(args)
return category
end
-----------------------------------------------------------------------
-- Utility: remove a value from an array
-----------------------------------------------------------------------
local function removeFromArray(t, delete)
local j = 1
local n = #t
for i = 1, n do
if t[i] ~= delete then
if i ~= j then
t[j] = t[i]
t[i] = nil
end
j = j + 1
else
t[i] = nil
end
end
return t
end
-----------------------------------------------------------------------
-- Export list of disambiguation types EXCEPT "TV series"
-- Used by the season module to detect incorrect infobox usage
-----------------------------------------------------------------------
function p.getDisambiguationTypeList()
return removeFromArray(mw.clone(validDisambiguationTypeList), "TV series")
end
-----------------------------------------------------------------------
-- Test entry point (returns debug string)
-----------------------------------------------------------------------
function p.test(frame)
local args = getArgs(frame)
local _, debugString = _main(args)
return debugString
end
return p