filyp / autocorrect

Spelling corrector in python
GNU Lesser General Public License v3.0
447 stars 79 forks source link

French Spell Checker #43

Closed oscar-defelice closed 2 years ago

oscar-defelice commented 2 years ago

I followed your instructions but I got an error when I try to count words from language corpus. I attach a screenshot here, but the error log is the following

~/miniconda3/envs/cs/lib/python3.8/site-packages/autocorrect/word_count.py in get_words(filename, lang, encd)
      7 
      8 def get_words(filename, lang, encd):
----> 9     word_regex = word_regexes[lang]
     10     capitalized_regex = r'(\.|^|<|"|\'|\(|\[|\{)\s*' + word_regexes[lang]
     11     with open(filename, encoding=encd) as file:

KeyError: 'fr'

My guess is that this is related to the key languages present in word_regexes dict.

image

oscar-defelice commented 2 years ago

After a bit of browsing in the code, I guess (but please correct me if I am wrong) what should be done in order to add a new language is

  1. first add the corresponding keys in autocorrect.constants dictionaries
  2. follow the readme instructions
filyp commented 2 years ago

You're right, I forgot to mention it in readme. Thanks for catching that! You need to add an entry both in word_regexes and alphabets dicts.