Skip to content

Commit 74a4537

Browse files
committed
Add basic spell checking, via Wikipedia:Lists of common misspellings/For machines
1 parent 46b2498 commit 74a4537

2 files changed

Lines changed: 4339 additions & 2 deletions

File tree

gan.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from theobot import password
99
from theobot import bot
10+
from theobot import spellcheck
1011

1112
from itertools import groupby
1213
import collections
@@ -80,13 +81,20 @@ def paragraph(lines):
8081
if not re.search(r"""(sfn|\<ref)""",p) and len(p) > 100: # only look at paragraphs longer than 100 chars
8182
alerts.append("\n* ''(beta)'' Lacking a citation in the paragraph beginning {{{{xt|{}...}}}}".format(p[:70]))
8283

84+
# check for common misspelled words from [[Wikipedia:Lists of common_misspellings/For machines]]
85+
print "Checking for misspelled words..."
86+
sp = []
87+
for spell_tuple in spellcheck.Misspellings(text).check():
88+
#for spell_tuple in spellcheck.Misspellings(text).check():
89+
sp.append("\"{0}\" (line {1})".format(spell_tuple[1],spell_tuple[0]))
90+
if len(sp) > 0:
91+
alerts.append("\n* Common typo(s) or misspelling(s) detected: " + ', '.join(sp))
92+
8393
if len(alerts) > 0:
8494
results += ''.join(alerts)
8595
else:
8696
results += "\n''There are no alerts for this page.''"
8797

88-
# !todo misspelled words?
89-
9098
return results
9199

92100
def cleanup(text):

0 commit comments

Comments
 (0)