Spaces:
Runtime error
Runtime error
jwkirchenbauer
commited on
Commit
•
acf4dce
1
Parent(s):
5e739ee
download spacy model if not present
Browse files- normalizers.py +9 -2
normalizers.py
CHANGED
@@ -158,9 +158,16 @@ class TrueCaser:
|
|
158 |
|
159 |
def __init__(self, backend="spacy"):
|
160 |
if backend == "spacy":
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
-
self.nlp = spacy.load("en_core_web_sm")
|
164 |
self.normalize_fn = self._spacy_truecasing
|
165 |
else:
|
166 |
from nltk import pos_tag, word_tokenize # noqa
|
|
|
158 |
|
159 |
def __init__(self, backend="spacy"):
|
160 |
if backend == "spacy":
|
161 |
+
spacy_model = "en_core_web_sm"
|
162 |
+
try:
|
163 |
+
import spacy
|
164 |
+
self.nlp = spacy.load(spacy_model)
|
165 |
+
except:
|
166 |
+
import spacy.cli
|
167 |
+
spacy.cli.download(spacy_model)
|
168 |
+
import spacy
|
169 |
+
self.nlp = spacy.load(spacy_model)
|
170 |
|
|
|
171 |
self.normalize_fn = self._spacy_truecasing
|
172 |
else:
|
173 |
from nltk import pos_tag, word_tokenize # noqa
|