Any experience or pointer on using a spell checker (aspell, ispell ?) with a
Python app ?
Many thanks by advance
--
Gilles
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
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
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>
And many thanks to all afterwards...
--
Gilles
> 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
Great... Many thanks JanC
--
Gilles
>> 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/
> 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?
> 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")
> 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.