grammar & spell check

Alex Martelli aleaxit at
Fri Dec 22 06:24:57 EST 2000

"Satheesh Babu" <vsbabu at> wrote in message
news:91u20g$pl3$1 at
> Hi,
> Is there any suggestions on what services/software I can use
> to do grammar/spell check? for English language.
> requirements:
> 1. given a text string, it should do the checks and return
> errors/suggestions report
> 2. Should be able to interface from Python
> 3. Preferably should work from Win32 systems
>       (that gives an idea, can't I use  MS Word's functions for this?)

Of course, if you can count on Word being present on
your target machine; Python, with win32all (already
present in the ActiveState distribution), is an excellent
COM client.

For example, here's a spell-check program in Python:

import win32com.client

msword = win32com.client.Dispatch("Word.Application")

string = "Here is some texxt with a coupple of problems"

for word in string.split():
    if msword.CheckSpelling(word):
       print "!%s! OK!" % word
       print "?%s? ->"%word,
       suggestions = msword.GetSpellingSuggestions(word)
       for suggest in suggestions:
           print suggest.Name,

!Here! OK!
!is! OK!
!some! OK!
?texxt? -> text texts
!with! OK!
!a! OK!
?coupple? -> couple couplet coupler coupled couples
!of! OK!
!problems! OK!


You'll need Word's online docs for VBA to learn all the
details about spell-checking and grammar-checking.

For a cross-platform and free solution, I would expect
you could wring something similar out of StarOffice 5.2,
but unfortunately I wouldn't know where to start to
get cross-platform interfacing of Python with SO 5.2
(on Windows, specifically, they probably expose some
COM object model -- but that wouldn't help your programs
run under, say, Linux).  Has anybody managed to drive
StarOffice from Python cross-platformly, btw...?


More information about the Python-list mailing list