Spaces:
Sleeping
Sleeping
Yaz Hobooti
commited on
Commit
·
9295381
1
Parent(s):
1baa0bd
Fix spellchecker import error: Use pyspellchecker with fallback imports
Browse files- app.py +13 -3
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -34,11 +34,18 @@ except Exception:
|
|
| 34 |
HAS_OCR = False
|
| 35 |
|
| 36 |
try:
|
|
|
|
| 37 |
from spellchecker import SpellChecker
|
|
|
|
|
|
|
| 38 |
HAS_SPELLCHECK = True
|
| 39 |
except Exception:
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
try:
|
| 44 |
import regex as re
|
|
@@ -497,7 +504,10 @@ from PIL import Image
|
|
| 497 |
import unicodedata
|
| 498 |
import regex as re
|
| 499 |
import pytesseract
|
| 500 |
-
|
|
|
|
|
|
|
|
|
|
| 501 |
|
| 502 |
# If these existed in your file, keep them; otherwise define defaults to avoid NameError
|
| 503 |
try:
|
|
|
|
| 34 |
HAS_OCR = False
|
| 35 |
|
| 36 |
try:
|
| 37 |
+
try:
|
| 38 |
from spellchecker import SpellChecker
|
| 39 |
+
except ImportError:
|
| 40 |
+
from pyspellchecker import SpellChecker
|
| 41 |
HAS_SPELLCHECK = True
|
| 42 |
except Exception:
|
| 43 |
+
try:
|
| 44 |
+
from pyspellchecker import SpellChecker
|
| 45 |
+
HAS_SPELLCHECK = True
|
| 46 |
+
except Exception:
|
| 47 |
+
SpellChecker = None
|
| 48 |
+
HAS_SPELLCHECK = False
|
| 49 |
|
| 50 |
try:
|
| 51 |
import regex as re
|
|
|
|
| 504 |
import unicodedata
|
| 505 |
import regex as re
|
| 506 |
import pytesseract
|
| 507 |
+
try:
|
| 508 |
+
from spellchecker import SpellChecker
|
| 509 |
+
except ImportError:
|
| 510 |
+
from pyspellchecker import SpellChecker
|
| 511 |
|
| 512 |
# If these existed in your file, keep them; otherwise define defaults to avoid NameError
|
| 513 |
try:
|
requirements.txt
CHANGED
|
@@ -5,7 +5,7 @@ pdf2image
|
|
| 5 |
gradio
|
| 6 |
PyMuPDF>=1.24
|
| 7 |
pytesseract
|
| 8 |
-
|
| 9 |
regex
|
| 10 |
pyzbar
|
| 11 |
zxing-cpp
|
|
|
|
| 5 |
gradio
|
| 6 |
PyMuPDF>=1.24
|
| 7 |
pytesseract
|
| 8 |
+
pyspellchecker
|
| 9 |
regex
|
| 10 |
pyzbar
|
| 11 |
zxing-cpp
|