http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9367
Revision: 9367 Author: xqt Date: 2011-07-11 04:50:03 +0000 (Mon, 11 Jul 2011) Log Message: ----------- display title for spellchecker, patch supmitted by loxley (patch bug #3355772)
Modified Paths: -------------- trunk/pywikipedia/spellcheck.py
Modified: trunk/pywikipedia/spellcheck.py =================================================================== --- trunk/pywikipedia/spellcheck.py 2011-07-11 04:36:01 UTC (rev 9366) +++ trunk/pywikipedia/spellcheck.py 2011-07-11 04:50:03 UTC (rev 9367) @@ -138,10 +138,10 @@ # uncapitalize the first word of the string return string[0].upper()+string[1:]
-def askAlternative(word,context=None): +def askAlternative(word, context=None, title=''): correct = None pywikibot.output(u"="*60) - pywikibot.output(u"Found unknown word '%s'"%word) + pywikibot.output(u"Found unknown word '%s' in '%s'" % (word, title)) if context: pywikibot.output(u"Context:") pywikibot.output(u""+context) @@ -256,7 +256,7 @@ result = result.replace('°',u'°') return result
-def spellcheck(page, checknames = True, knownonly = False): +def spellcheck(page, checknames = True, knownonly = False, title=''): pageskip = [] text = page if correct_html_codes: @@ -274,7 +274,8 @@ if not Word(smallword).isCorrect(checkalternative = knownonly) and \ (checknames or not smallword[0].isupper()): replacement = askAlternative(smallword, - context=text[max(0,loc-40):loc + len(match.group(2))+40]) + context=text[max(0,loc-40):loc + len(match.group(2))+40], + title=title) if replacement == edit: import editarticle editor = editarticle.TextEditor() @@ -504,7 +505,7 @@ pass else: text = spellcheck(text, checknames=checknames, - knownonly=knownonly) + knownonly=knownonly, title=page.title()) if text != page.get(): page.put(text) elif start: @@ -515,7 +516,7 @@ pass else: text = spellcheck(text, checknames=checknames, - knownonly=knownonly) + knownonly=knownonly, title=page.title()) if text != page.get(): page.put(text)
@@ -527,7 +528,7 @@ pass else: text = spellcheck(text, checknames=checknames, - knownonly=knownonly) + knownonly=knownonly, title=page.title()) if text != page.get(): page.put(text)
@@ -542,7 +543,7 @@ except pywikibot.IsRedirectPage: print "Page is a redirect page" else: - text = spellcheck(text,knownonly=knownonly) + text = spellcheck(text,knownonly=knownonly, title=page.title()) if text != page.get(): page.put(text) title = pywikibot.input(u"Which page to check now? (enter to stop)")
pywikipedia-svn@lists.wikimedia.org