Skip to content

Commit

Permalink
Merge pull request #67 from microsoft/auto_download_spacy_language_mo…
Browse files Browse the repository at this point in the history
…dule

Automatically download spacy's en_core_web_sm if needed.
  • Loading branch information
MarcCote authored Nov 26, 2023
2 parents 73396ae + 127d4bb commit 6ead600
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
11 changes: 5 additions & 6 deletions jericho/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ def clean(s):
def _load_spacy():
""" Loads spacy into the global namespace. """
if 'spacy_nlp' not in globals():
global spacy_nlp
import spacy
try:
global spacy_nlp
import en_core_web_sm
spacy_nlp = en_core_web_sm.load()
except Exception as e:
print("Failed to load \'en\' with exception {}. Try: python -m spacy download en_core_web_sm".format(e))
raise
spacy_nlp = spacy.load("en_core_web_sm")
except OSError:
spacy.cli.download("en_core_web_sm")
spacy_nlp = spacy.load("en_core_web_sm")


def tokenize(str):
Expand Down
2 changes: 1 addition & 1 deletion jericho/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.2'
__version__ = '3.1.3'
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from setuptools import setup
from setuptools.command.install import install
from distutils.command.build import build
from distutils.core import setup, Extension
from distutils.core import setup
import os.path, sys
import subprocess

Expand Down

0 comments on commit 6ead600

Please sign in to comment.