PDA

View Full Version : Python and Enchant


Lavene
06-25-2006, 12:16 AM
Hi people! Thought I'd follow the LN crowd and register here. And to my surprice (!) I was already registered. My memory is not what it used to be :P

Anyway, I'm playing around with Python and right now I'm looking at the Enchant spellchecker module. My problem is that I can only make it work with 'aspell' wheras I rather would like to use 'myspell' or even 'ispell'.

Acording to the PyEnchant FAQ (http://pyenchant.sourceforge.net/faq.php) it should be possible to use either so I guess I'm missing something really basic here :oops:

My testcode:

import enchant

dictionary = enchant.Dict('en')
word = (raw_input("Please enter word to check: "))

if dictionary.check(word):
print "Correct"
else:
print dictionary.suggest(word)


Thanks
Tina

danieldk
06-25-2006, 04:03 AM
The enchant manual page says it all:


Enchant has a global and a per-user ordering file called enchant.ordering.
It lets the user specify which spelling backend to use for individual
languages in the case when you care which backend gets used. This global file
is located in $(datadir)/enchant; the per-user file is located in ~/.enchant.
The per-user file takes precedence, if found.

The ordering file takes the form language_tag:<comma-separated list of spelling
backends>. I am currently aware of the following backends: aspell, myspell, ispell, uspell, hspell. The comma-separated list may not include spaces. '*' is
used to mean "use this ordering for all languages, unless instructed otherwise." For example:

*:aspell,myspell,ispell

en:aspell,myspell,ispell

en_UK:myspell,aspell,ispell


The idea is that the program should not have to worry about which backend is used.

Lavene
06-25-2006, 04:24 AM
The idea is that the program should not have to worry about which backend is used.

Yeah, I know, that's what makes it so darn weird. For some reason it seem oblivious about any other dictionary than aspell, giving an error saying it can't find the wordlist. But the wordlists is indeed present.

Think I'll file a bugreport on it...

Tina