From 61732c9a2df3fe9b9d814bdce678dee87f16cc76 Mon Sep 17 00:00:00 2001 From: Felix <65565033+fexfl@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:16:28 +0100 Subject: [PATCH] Fixed the model download in init_spacy --- mailcom/parse.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/mailcom/parse.py b/mailcom/parse.py index e0579c6..472c352 100644 --- a/mailcom/parse.py +++ b/mailcom/parse.py @@ -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,