Skip to content

Commit

Permalink
Fixed the model download in init_spacy
Browse files Browse the repository at this point in the history
  • Loading branch information
fexfl committed Oct 29, 2024
1 parent 2f13356 commit 61732c9
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions mailcom/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,18 @@ def init_spacy(self, language: str, model="default"):
model, exclude=["morphologizer", "attribute_ruler", "lemmatizer", "ner"]
)
except OSError:
pass
try:
print(
"Could not find model in standard directory. Trying to download model from repo." # noqa
)
# try downloading model
sp.cli.download(model)
self.nlp_spacy = sp.load(
model,
exclude=["morphologizer", "attribute_ruler", "lemmatizer", "ner"],
)
except SystemExit:
raise SystemExit("Could not download {} from repo".format(model))
except OSError:
raise OSError("Could not find {} in standard directory".format(model))
try:
print(
"Could not find model in standard directory. Trying to download model from repo." # noqa
)
# try downloading model
sp.cli.download(model)
self.nlp_spacy = sp.load(
model,
exclude=["morphologizer", "attribute_ruler", "lemmatizer", "ner"],
)
except SystemExit:
raise SystemExit("Could not download {} from repo".format(model))

def init_transformers(
self,
Expand Down

0 comments on commit 61732c9

Please sign in to comment.