Created
January 22, 2016 14:39
-
-
Save shokai/f7f31edabe2a23910b88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("start"); | |
| function isSpam(page){ | |
| if(page.text.trim() === "(empty)") return true; | |
| var desc = page.text | |
| .replace(/\[{2,3}([^\[\]]+)\]{2,3}/g, "") | |
| .replace(/[\n\s\t]/g, ""); | |
| if(desc.length < 1) return true; // gyazz-tag 以外に解説文が無ければspam | |
| if(!(/\[\[.+\]\]/.test(page.text))) return true; // 他ページへのリンクが無いページはspam | |
| if(/\n/.test(page.text)) return false; // 本文が2行以上あればok | |
| if(/^https?:\/\/.+/.test(page.text)) return true; // URL1行だけしかないspam | |
| return false; | |
| } | |
| var query = {wiki: "osusume"}; | |
| print(db.pages.count(query) + "pages"); | |
| var cursor = db.pages.find(query); | |
| while(cursor.hasNext()){ | |
| var page = cursor.next(); | |
| if(isSpam(page)){ | |
| print("spam: " + page.title); | |
| } | |
| else{ | |
| printjson(page); | |
| db.pages.insert({ | |
| wiki: "推薦", | |
| title: page.title, | |
| text: page.text, | |
| timestamp: page.timestamp | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment