Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/RexxS/Dabcheck
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[[ Helper function that checks a piece of text with 3-way match: valid match, invalid match, no match It returns 3 configurable results. The function test tests if a title contains a valid disabiguator. --]] local p = {} -- exportable to other modules function p._3way_check(text, args) if not text or text == "" then return false, "no text" end -- Check if there is a match on the valid list for _, v in ipairs(args.valid) do if text:match(v) then return true, "" end end -- Check if there is a match on the invalid list for k, v in pairs(args.invalid) do if text:match(k) then return false, v end end -- if we've got this far, then there's no match return false, args.nomatch end function p.test(frame) local title = frame.args.title or "" if title == "" then return "No title" end local exceptionList = { "The (206)", "Cinderella (Apakah Cinta Hanyalah Mimpi?)", "How to Live with Your Parents (For the Rest of Your Life)", "I (Almost) Got Away With It", "Monty Python: Almost the Truth (Lawyers Cut)", "Randall and Hopkirk (Deceased)", "Randall & Hopkirk (Deceased) (2000 TV series)" } -- finish if the title has brackets that are part of the title (not disambiguation) for _, v in ipairs(exceptionList) do if v == title then return "Title on exception list" end end -- extract the disambiguation text local disambiguation = string.match(title, "%s%((.-)%)") -- set up the three possibilities local args = { valid = { "TV series", "TV program", "TV programme", "TV film", "film", "miniseries", "serial", "game show", "talk show", "web series" }, invalid = { -- for testing we'll just see the category, not categorise the page ["franchise"] = "[[:Category:Television articles using incorrect infobox - F]]", ["season"] = "[[:Category:Television articles using incorrect infobox - S]]" -- ["franchise"] = "[[Category:Television articles using incorrect infobox|F]]", -- ["season"] = "[[Category:Television articles using incorrect infobox|S]]" }, -- for testing we'll just see the category, not categorise the page nomatch = "[[:Category:Television articles with incorrect naming style]]" } local validmatch, msg = p._3way_check(disambiguation, args) if validmatch then return "Valid title" else return msg end end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/RexxS/Dabcheck/doc
(
edit
)