ഉപയോക്താവ്:UltraBot/correct dsamb.py

വിക്കിപീഡിയ, ഒരു സ്വതന്ത്ര വിജ്ഞാനകോശം.
Jump to navigation Jump to search
import wikipedia
import codecs
import re

NEWLINE = u'\u000d\u000a'

# Chill pairs
oldChilluNN = u'\u0D23\u0D4D\u200D' # old chillu NN
newChilluNN = u'\u0D7A' # new chillu NN

oldChilluN  = u'\u0D28\u0D4D\u200D' # old chillu N
newChilluN  = u'\u0D7B' # new chillu N

oldChilluRR=u'\u0d30\u0d4d\u200d'  # old chillu RR
newChilluRR=u'\u0d7c' # new chillu R

oldChilluL  = u'\u0D32\u0D4D\u200D' # old chillu L
newChilluL  = u'\u0D7D' # new chillu L

oldChilluLL = u'\u0D33\u0D4D\u200D' # old chillu LL
newChilluLL = u'\u0D7E' # new chillu LL

oldChilluK  = u'\u0d15\u0D4D\u200D' #old chillu K
newChilluK  = u'\u0D7F' # new chillu K

oldNT = u'\u0d28\u0d4d\u0D31'
newNT = u'\u0D7B\u0D4D\u0D31'

# function to replace old chills with new ones
def replace_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)
    return newString

def correct_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)
    if matchobj:
        str2 = matchobj.group(0)
        str3 = replace_chills(str2)
        newtxt = txt.replace(str2,str3)
        if txt != 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)
for p in pages:
    done = correct_dsamb(p)
    log.write(p.title() +  ("- done" if done else " not done") + NEWLINE)

log.flush()
log.close()
"https://ml.wikipedia.org/w/index.php?title=ഉപയോക്താവ്:UltraBot/correct_dsamb.py&oldid=610940" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്