Module:Infobox television disambiguation check: Difference between revisions
NeonWabbit (talk | contribs) Created page with "-- This module requires the use of the following modules. local getArgs = require('Module:Arguments').getArgs local validateDisambiguation = require('Module:Television infoboxes disambiguation check') local p = {} local validDisambiguationTypeList = { "TV series", "TV programme", "TV program", "TV film", "film", "miniseries", "serial", "game show", "talk show", "web series" } local validDisambiguationPatternList = { validateDisambiguation.DisambiguationPat..." |
NeonWabbit (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
require("strict") | |||
local getArgs = require( | |||
local validateDisambiguation = require( | local getArgs = require("Module:Arguments").getArgs | ||
local validateDisambiguation = require("Module:Television infoboxes disambiguation check") | |||
local p = {} | local p = {} | ||
----------------------------------------------------------------------- | |||
-- Valid disambiguation types for infobox television | |||
----------------------------------------------------------------------- | |||
local validDisambiguationTypeList = { | local validDisambiguationTypeList = { | ||
"TV series", | "TV series", | ||
| Line 18: | Line 22: | ||
} | } | ||
local validDisambiguationPatternList | ----------------------------------------------------------------------- | ||
validateDisambiguation.DisambiguationPattern{pattern = "^(%d+) (%D+)", type = | -- Valid disambiguation patterns (AFTER removing type) | ||
validateDisambiguation.DisambiguationPattern{pattern = "^%d+$", type = | ----------------------------------------------------------------------- | ||
validateDisambiguation.DisambiguationPattern{pattern = "^%D+$", 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 = { | local exceptionList = { | ||
"The (206)", | "The (206)", | ||
| Line 33: | Line 57: | ||
"Deal or No Deal Malaysia (English-language game show)", | "Deal or No Deal Malaysia (English-language game show)", | ||
"Deal or No Deal Malaysia (Mandarin-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 Live with Your Parents (For the Rest of Your Life)", | ||
"How to Sell Drugs Online (Fast)", | "How to Sell Drugs Online (Fast)", | ||
"I (Almost) Got Away With It", | "I (Almost) Got Away With It", | ||
"I Do (But I Don't)", | |||
"Kevin (Probably) Saves the World", | "Kevin (Probably) Saves the World", | ||
"Love (ft. Marriage and Divorce)", | "Love (ft. Marriage and Divorce)", | ||
| Line 44: | Line 70: | ||
"Wednesday 9:30 (8:30 Central)", | "Wednesday 9:30 (8:30 Central)", | ||
"Who the (Bleep)...", | "Who the (Bleep)...", | ||
"Who the (Bleep) Did I Marry?" | "Who the (Bleep) Did I Marry?" | ||
} | } | ||
----------------------------------------------------------------------- | |||
-- Infoboxes that should NOT use this module | |||
----------------------------------------------------------------------- | |||
local otherInfoboxList = { | local otherInfoboxList = { | ||
["franchise"] = "[[Category:Television articles using incorrect infobox|FRANCHISE]]", | ["franchise"] = "[[Category:Television articles using incorrect infobox|FRANCHISE]]", | ||
| Line 56: | Line 85: | ||
} | } | ||
-- | ----------------------------------------------------------------------- | ||
-- No invalid title styles for this module | |||
----------------------------------------------------------------------- | |||
local invalidTitleStyleList = {} | local invalidTitleStyleList = {} | ||
----------------------------------------------------------------------- | |||
-- Internal main | |||
----------------------------------------------------------------------- | |||
local function _main(args) | local function _main(args) | ||
local title = args[1] | local title = args[1] | ||
return validateDisambiguation.main(title, "infobox television", validDisambiguationTypeList, validDisambiguationPatternList, exceptionList, otherInfoboxList, invalidTitleStyleList) | return validateDisambiguation.main( | ||
title, | |||
"infobox television", | |||
validDisambiguationTypeList, | |||
validDisambiguationPatternList, | |||
exceptionList, | |||
otherInfoboxList, | |||
invalidTitleStyleList | |||
) | |||
end | end | ||
----------------------------------------------------------------------- | |||
-- Public entry point | |||
----------------------------------------------------------------------- | |||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local category | local category = _main(args) | ||
return category | return category | ||
end | end | ||
----------------------------------------------------------------------- | |||
-- Utility: remove a value from an array | |||
----------------------------------------------------------------------- | |||
local function removeFromArray(t, delete) | 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 | end | ||
----------------------------------------------------------------------- | |||
-- Export list of disambiguation types EXCEPT "TV series" | |||
-- Used by the season module to detect incorrect infobox usage | |||
----------------------------------------------------------------------- | |||
function p.getDisambiguationTypeList() | function p.getDisambiguationTypeList() | ||
return removeFromArray(validDisambiguationTypeList, "TV series") | return removeFromArray(mw.clone(validDisambiguationTypeList), "TV series") | ||
end | end | ||
----------------------------------------------------------------------- | |||
-- Test entry point (returns debug string) | |||
----------------------------------------------------------------------- | |||
function p.test(frame) | function p.test(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local | local _, debugString = _main(args) | ||
return debugString | return debugString | ||
end | end | ||
return p | return p | ||