词条 | Module:Sandbox/Ypnypn/Review |
释义 | 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..'\' 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 '''"..page.."''' has some problems:\"..result end return result end end function critique(content) prose = content prose = string.gsub(prose, '{|.-|}', '') prose = string.gsub(prose, '[1]', '') prose = string.gsub(prose, '%[%[Category:.-%]%]', '') prose = string.gsub(prose, '%[%[File:.-%]%]', '') prose = string.gsub(prose, '%b{}', '') --infobox if not string.match(content, '{{Infobox') then issues['infobox'] = 'none' end --categories if not string.match(content, '%[%[Category:') then issues['category'] = 'none' elseif not string.match(content, '%[%[Category:.+%[%[Category:') then issues['category'] = 'one' end --length length = #prose if length > 100000 then issues['length'] = 'too long' elseif length < 10000 then issues['length'] = 'too short' end end function text(issue, details) if issue == 'infobox' and details == 'none' then return '* There is no infobox.\' end if issue == 'category' then if details == 'none' then return '* There are no categories.\' elseif details == 'one' then return '* There is only one category.\' end end if issue == 'length' then if details == 'too long' then return '* The article is very long.\' elseif details == 'too short' then return '* The article is very short.\' end end end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。