![]() | This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
The module “Sandbox/Ypnypn/Review” provides an automated review of an article, pointing out possible flaws.
Usage
{{#invoke:Sandbox/Ypnypn/Review|review|page name}}
Parameters
The first parameter, also available through |page=
, indicates the page to be analyzed.
The second parameter, also available through |plain=
, has the module return a plain, non-descriptive list of issues. This is not recommended.
local p = {}
function p.review(frame)
page = frame.args['page'] or frame.args[1]
article = mw.title.new(page,'')
content = article:getContent()
result = ''
issues = critique(content)
if frame.args['plain'] then
for issue, details in pairs(issues) do
result = result..'# '..issue..' = '..details..'\n'
end
return result
else
for issue, details in pairs(issues) do
result = result..text(issue, details)
end
if result == '' then
result = 'The article is perfect!'
else
result = 'The article has some problems:\n'..result
end
return result
end
end
function critique(content)
issues = {}
--infobox
if not string.match(content, '{{Infobox') then
issues['infobox'] = 'false'
end
--categories
if not string.match(content, '%[%[Category:') then
issues['category'] = 'none'
elseif not string.match(content, '%[%[Category:.+%[%[Category:') then
issues['category'] = 'one'
end
return issues
end
function text(issue, details)
if issue == 'infobox' then
return '* There is no infobox.\n'
end
if issue == 'category' then
if details == 'none' then
return '* There are no categories.\n'
elseif details == 'one' then
return '* There is only one category.\n'
end
end
return '<strong>Error: issue not found! Issue: '..issue..' = '..details..'</strong'
end
return p