Skip to content

Improve error handling for SpacyPreprocessor without model #1458

@bhancock8

Description

@bhancock8

Is your feature request related to a problem? Please describe.

The first time a user tries to use the SpacyPreprocessor, they hit they following error:

  File "<stdin>", line 1, in <module>
  File "/Users/braden/anaconda3/lib/python3.7/site-packages/spacy/__init__.py", line 27, in load
    return util.load_model(name, **overrides)
  File "/Users/braden/anaconda3/lib/python3.7/site-packages/spacy/util.py", line 139, in load_model
    raise IOError(Errors.E050.format(name=name))
OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

Describe the solution you'd like

We know the line where the spacy model is called (

self._nlp = spacy.load(language, disable=disable or [])
) and should be able to catch that Exception and download it if its missing.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions