importwikipediaimportcodecsimportreNEWLINE=u'\u000d\u000a'# Chill pairsoldChilluNN=u'\u0D23\u0D4D\u200D'# old chillu NNnewChilluNN=u'\u0D7A'# new chillu NNoldChilluN=u'\u0D28\u0D4D\u200D'# old chillu NnewChilluN=u'\u0D7B'# new chillu NoldChilluRR=u'\u0d30\u0d4d\u200d'# old chillu RRnewChilluRR=u'\u0d7c'# new chillu RoldChilluL=u'\u0D32\u0D4D\u200D'# old chillu LnewChilluL=u'\u0D7D'# new chillu LoldChilluLL=u'\u0D33\u0D4D\u200D'# old chillu LLnewChilluLL=u'\u0D7E'# new chillu LLoldChilluK=u'\u0d15\u0D4D\u200D'#old chillu KnewChilluK=u'\u0D7F'# new chillu KoldNT=u'\u0d28\u0d4d\u0D31'newNT=u'\u0D7B\u0D4D\u0D31'# function to replace old chills with new onesdefreplace_chills(oldString):newString=oldString.replace(oldChilluNN,newChilluNN)newString=newString.replace(oldChilluN,newChilluN)newString=newString.replace(oldChilluRR,newChilluRR)newString=newString.replace(oldChilluL,newChilluL)newString=newString.replace(oldChilluLL,newChilluLL)newString=newString.replace(oldChilluK,newChilluK)# തൽക്കാലം ന്റ യെ ഒഴിവാകുന്നു#newString=newString.replace(oldNT, newNT)returnnewStringdefcorrect_dsamb(page):wikipedia.output("Processing page"+page.title())txt=page.get(get_redirect=True)matchobj=re.search(ur'\{\{\s*?(ToDisambig|ToDiasmbig|നാനാര്ത്ഥം|നാനാർത്ഥം|വിവക്ഷ)\s*?\|.*?\}\}',txt,re.U)ifmatchobj:str2=matchobj.group(0)str3=replace_chills(str2)newtxt=txt.replace(str2,str3)iftxt!=newtxt:page.put(newtxt,ur'നാനാർത്ഥം ശരിയാക്കുന്നു')else:wikipedia.output(" No change required")else:wikipedia.output(" template not found")siteFamily="wikipedia"siteLangCode="ml"wikiSite=wikipedia.Site(code=siteLangCode,fam=siteFamily)disambigT=wikipedia.Page(site=wikiSite,title=ur'ഫലകം:ToDisambig')log=codecs.open('correct_dsamb.txt',mode="w+",encoding='utf-8')pages=disambigT.getReferences(onlyTemplateInclusion=True)forpinpages:done=correct_dsamb(p)log.write(p.title()+("- done"ifdoneelse" not done")+NEWLINE)log.flush()log.close()