0

For context I'm trying to use PyEnchant for a uni project where I write ciphers and try to decipher text without knowing the key, and pyenchant is meant to work as a verification for when the text has been deciphered since it should detect once the deciphering algorithm is returning real words in the dictionary.

My issue is coming from trying to use the French dictionary. Now yesterday all was fine, and it was working, but since I tried to make it work on my other computer and now the French dictionary isn't working at all (but the English dictionary is working just fine). For example check("Bonjour") returns false and suggest("Bonj") returns an empty array...

I tried to reinstall pyenchant and have manually re-added the .aff and .dic files for the french dictionary but it hasn't changed anything, whats going on?

import enchant

de = enchant.Dict("en_US")
df = enchant.Dict("fr")
print(df.check("bonjour"))
print(enchant.dict_exists("fr"))
print(de.check("hello"))

>>False
>>True
>>True

For information I placed the .aff and .dic files in my hunspell folder, and it worked yesterday so I dont see why it wouldn't work today

Jeromeo
  • 45
  • 6
  • 1
    Your code is fine, so it must be a problem with installation, either of pyenchant or of the hunspell files. Which operating system, and what is the path to the hunspell folder? Try `pip show pyenchant` to make sure that the instance of python you're running is the one where you put the .dic and .aff files. – Jim K Feb 04 '23 at 02:07
  • 1
    As an example, I got it to work on Windows by placing `fr.aff` and `fr.dic` in this path: `C:\Users\(username)\AppData\Roaming\Python\Python38\site-packages\enchant\data\mingw64\share\enchant\hunspell`. Make sure the .aff and .dic files have the contents that you expect and are not corrupted. – Jim K Feb 04 '23 at 02:11
  • After I saw your message I tried to run my script again, refreshing the .aff and .dic files, and It suddenly worked. I have no idea why I guess you must be rigth and it was a faulty installation. Thanks for the help anyway @JimK – Jeromeo Feb 08 '23 at 08:38

0 Answers0