Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Spell checking and Python

0 views
Skip to first unread message

Gilles Lenfant

unread,
Dec 15, 2003, 2:46:03 PM12/15/03
to
Hi pythonists,

Any experience or pointer on using a spell checker (aspell, ispell ?) with a
Python app ?

Many thanks by advance

--
Gilles


Dave Kuhlman

unread,
Dec 15, 2003, 8:01:04 PM12/15/03
to
Gilles Lenfant wrote:

Here is one way for UNIX/Linux running with X Windows:

def check(content):
file = open('ispell.tmp', 'w')
file.write(content)
file.close()
os.system('xterm -e ispell ispell.tmp')
file = open('ispell.tmp', 'r')
content = file.read()
file.close()
return content


You might want to use the tempfile module in the Python standard
library to create the temporary file, though.

Dave

--
http://www.rexx.com/~dkuhlman
dkuh...@rexx.com

Tim Churches

unread,
Dec 16, 2003, 1:39:06 AM12/16/03
to Gilles Lenfant, python-list @ python . org
Gilles Lenfant <glen...@NOSPAM.bigfoot.com> wrote:
>
> Hi pythonists,
>
> Any experience or pointer on using a spell checker (aspell, ispell ?)
> with a
> Python app ?

It is not too hard to interface Python to aspell running in pipe mode using popen2
etc, and that works OK, but you then need to parse the results returned by aspell.
In the end I re-implemented aspell-style look-ups in Python, holding the entire
dictionary in a dict, indexed in various ways (allowing phonetic and other fuzzy
look-ups). Works a treat.

Tim C

Martin Franklin

unread,
Dec 16, 2003, 4:31:57 AM12/16/03
to Python List

quick google for python cookbook then search for spell produces this:-


http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117221


Cheers,
Martin.
--
Martin Franklin <mfran...@gatwick.westerngeco.slb.com>


Gilles Lenfant

unread,
Dec 16, 2003, 6:07:05 AM12/16/03
to

"Gilles Lenfant" <glen...@NOSPAM.bigfoot.com> a écrit dans le message de
news:brl2vb$1dj$1...@biggoron.nerim.net...


And many thanks to all afterwards...

--
Gilles


JanC

unread,
Dec 17, 2003, 1:03:31 AM12/17/03
to
"Gilles Lenfant" <glen...@NOSPAM.bigfoot.com> schreef:

> Any experience or pointer on using a spell checker (aspell, ispell ?)
> with a Python app ?

Maybe snakespell: <http://www.scriptfoundry.com/modules/snakespell/>

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9

Gilles Lenfant

unread,
Dec 17, 2003, 1:48:34 PM12/17/03
to

"JanC" <usene...@janc.invalid> a écrit dans le message de
news:Xns945447C...@213.119.4.35...

Great... Many thanks JanC

--
Gilles


Jarek Zgoda

unread,
Dec 17, 2003, 3:06:58 PM12/17/03
to
JanC <usene...@janc.invalid> pisze:

>> Any experience or pointer on using a spell checker (aspell, ispell ?)
>> with a Python app ?
>
> Maybe snakespell: <http://www.scriptfoundry.com/modules/snakespell/>

Maybe myspell-python?

http://www.zgoda.biz/dnld/myspell-python-1.0-minimal.tar.gz

This is repackaged original library by Karl W. MacMillan. I finally
found a maitainer for this piece of code and I hope it will be actively
developed.

--
Jarek Zgoda
Unregistered Linux User # -1
http://www.zgoda.biz/ JID:zg...@chrome.pl http://zgoda.jogger.pl/

Ken Godee

unread,
Dec 17, 2003, 4:16:22 PM12/17/03
to Jarek Zgoda, pytho...@python.org
Jarek Zgoda wrote:

> JanC <usene...@janc.invalid> pisze:
>
>
>>>Any experience or pointer on using a spell checker (aspell, ispell ?)
>>>with a Python app ?
>>
>>Maybe snakespell: <http://www.scriptfoundry.com/modules/snakespell/>
>
>
> Maybe myspell-python?
>
> http://www.zgoda.biz/dnld/myspell-python-1.0-minimal.tar.gz
>
> This is repackaged original library by Karl W. MacMillan. I finally
> found a maitainer for this piece of code and I hope it will be actively
> developed.
>

I recently (july) wrote a small spell check program using
myspell-python and thought it was far better than anything out
there and then it seemed to just drop off the face of the planet.
Where do you think it's going to be maintained so I can book mark it?

William Trenker

unread,
Dec 18, 2003, 8:29:10 AM12/18/03
to pytho...@python.org
Jarek Zgoda wrote:

> Maybe myspell-python?
>
> http://www.zgoda.biz/dnld/myspell-python-1.0-minimal.tar.gz
>
> This is repackaged original library by Karl W. MacMillan. I finally
> found a maitainer for this piece of code and I hope it will be actively
> developed.

Might want to apply the following patch to __init__.py so that the dictionary files are located relative to the installation directory. When I first tried running myspell-python (Linux Python 2.3.2) I got a traceback -- the dictionary path was wrong compared with where setup.py actually installed the dictionaries.

After the fix, myspell-python worked very well. The list of suggested spellings for a given word is quite good.

Bill

--- __init__.py-original Wed Jun 11 13:41:23 2003
+++ __init__.py Thu Dec 18 13:18:24 2003
@@ -39,7 +39,7 @@
# break on other platforms.
self.dicts_path = sys.prefix + "/myspell-dicts/"
if sys.platform != 'win32':
- self.dicts_path = "/usr/share/myspell-dicts/"
+ self.dicts_path = sys.prefix + "/share/myspell-dicts/"
core.MySpellBase.__init__(self, self.dicts_path + "en_US.aff",
self.dicts_path + "en_US.dic")

Jarek Zgoda

unread,
Dec 19, 2003, 3:31:49 PM12/19/03
to
William Trenker <wtre...@shaw.ca> pisze:

> Might want to apply the following patch to __init__.py so that the
> dictionary files are located relative to the installation directory.
> When I first tried running myspell-python (Linux Python 2.3.2) I got a
> traceback -- the dictionary path was wrong compared with where
> setup.py actually installed the dictionaries.
>
> After the fix, myspell-python worked very well. The list of suggested
> spellings for a given word is quite good.

Of course, all pathes, fixes and suggestions are welcome. I hope that
this piece of code finally find it's safe harbor at Savannah or SF. I
think that other people also find it worth using.

0 new messages