Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.
UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.
Python:CorrectTyop.py
# DRAFT # TO BE TESTED # ROBOT REQUESTED BY MEMBERS OF ZH:WIKIPEDIA # c.f.: #http://zh.wikipedia.org/w/index.php?title=Wikipedia:%E6%9C%BA%E5%99%A8%E4%BA%BA/%E6%8F%90%E8%AE%AE&variant=zh-tw # 自動把「膺品」改成「贗品」的機器人 #SET-UP pageNameList=[u'數學', u'物理', u'生物', u'音樂',] # LIST YOUR PAGES HERE # LIST OF CONVERSIONS typoList= [ (ur'膺品',ur'贗品'), (ur'修茸',ur'修葺'), (ur'謚號',ur'諡號'), ] #IMPORTS import re import wikipedia # COMPILE THE REGEX LIST typoXList=[] for i,j in typoList: typoXList.append((re.compile(i), flags=re.U),j) # ADD THE PAIR (REGEX,REPLACEMENT) TO THE END OF THE LIST # GET THE SITE OBJECT site = wikipedia.getSite() # MAIN LOOP for pageName in pageNameList: print '-------------------------------------------------------\n' print '[[' + pageName + ']]:' page = wikipedia.Page( site, pageName) # CREATE PAGE OBJECT text=page.get() # GET THE TEXT OF THE PAGE typoFound = False #SET FLAG for r,s in typoXList: text, count= r.subn(s,text) # REPLACE ANY OCCURANCE OF r IN text BY s if count > 0: print count, 'typo found, converted to', s typoFound = True if typoFound: page.put(text,'機修錯別字:[[botwiki:Python:CorrectTyop.py]]') print('page [[' + pageName + ']] modified. \n') wikipedia.stopme()