adam-faulkner / PyAutoSpell

A Python library that automatically corrects English text by re-ranking corrections with an ngram model.
MIT License
4 stars 0 forks source link

Setup issue: ImportError: libhunspell-1.3.so.0: cannot open shared object file: No such file or directory #1

Closed mit456 closed 6 years ago

mit456 commented 6 years ago

Hello,

Thanks for sharing the project, I got all the resources, and I am trying to setup but inside virtualenv. Steps followed to setup:

  1. clone project.
  2. make project a virtaulenv project, virtualenv -p python3 ./
  3. pip install -r requirements.txt

After this, I tried to import AutoChecker like from autospell.autochecker import AutoChecker but getting following error,

ImportError: libhunspell-1.3.so.0: cannot open shared object file: No such file or directory

Any idea why it could be? Did I make any mistake in setup?

adam-faulkner commented 6 years ago

Hi-- So, I've restructured the entire project and added a setup.py for easy installation. You should probably get rid of your current install, re-clone, and follow the new setup instructions I've included in the README. Note, in particular, the installation pitfalls related to the CyHunspell dependency. Your ibhunspell-1.3.so.0 error is almost certainly related to a failed install of this project since CyHunspell should include hunspell in its install after first checking to see if it's already installed. Note that all of this assumes that you're on OSX. Let me know if all of this works!

mit456 commented 6 years ago

Hello,

Thanks for your prompt reply, I am using Linux not OSX but now it works, I had to uninstall CyHunspell and reinstall again and it started working but I am facing another issue,

corrections = auto_checker.correct_spelling("Watching youself from an outsde perspectve")

The above statement works well and it gets corrected as Watching yourself from an outside prespective but when I do

corrections = auto_checker.correct_spelling("Watching youself from an outs de perspect ve")

I get

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-43-428cb724747a> in <module>()
----> 1 corrections = auto_checker.correct_spelling("Watching yourself from an outs de perspect ve")

~/Projects/streamingo_ocr/lib/python3.6/site-packages/pyautospell/autochecker.py in correct_spelling(self, text)
     76         :return:
     77         '''
---> 78         correction = self.spell_corrector.correct_spelling(text)
     79         return correction
     80 

~/Projects/streamingo_ocr/lib/python3.6/site-packages/pyautospell/spell_corrector_ranked.py in correct_spelling(self, text)
     25         '''
     26         misspellings = self.spell_checker.check_spelling(text, 10)
---> 27         self.candidate_scorer.candidate_scoring(misspellings, text)
     28         corrected = self.suggestion_selector.select(text, misspellings)
     29         return Correction(text,corrected, misspellings)

~/Projects/streamingo_ocr/lib/python3.6/site-packages/pyautospell/suggestion_scorer_lm.py in candidate_scoring(self, misspelllist, sentence)
     62                 features = [0,0]
     63                 text = suggestion.text
---> 64                 words = self.tokenizer.tokenize(text) #a list of Word objects
     65                 head = words[0].word
     66                 tail = words[len(words) - 1].word

~/Projects/streamingo_ocr/lib/python3.6/site-packages/pyautospell/simple_tokenizer.py in tokenize(self, line)
     15             return list()
     16         pattern = re.compile("[\\w']+|[^\\w\\s]+")
---> 17         matches = re.finditer(pattern, line)
     18         for match in matches:
     19             wd = Word(line[match.start():match.end()], match.start(), match.end())

~/Projects/streamingo_ocr/lib/python3.6/re.py in finditer(pattern, string, flags)
    227 
    228     Empty matches are included in the result."""
--> 229     return _compile(pattern, flags).finditer(string)
    230 
    231 def compile(pattern, flags=0):

TypeError: expected string or bytes-like object

Why?

adam-faulkner commented 6 years ago

Hi, I just pushed a fix and tested things on several hundred thousand sentences. Let me know if that works.