mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 18:26:30 +03:00
Add load_test_model function with importorskip()
Loads model only if it can be imported, i.e. if it's installed as a package.
This commit is contained in:
parent
ad3c8b3ad9
commit
795fe43a4d
|
@ -4,9 +4,20 @@ from __future__ import unicode_literals
|
|||
from ..tokens import Doc
|
||||
from ..attrs import ORTH, POS, HEAD, DEP
|
||||
|
||||
import pytest
|
||||
import numpy
|
||||
|
||||
|
||||
MODELS = {}
|
||||
|
||||
|
||||
def load_test_model(model):
|
||||
if model not in MODELS:
|
||||
module = pytest.importorskip(model)
|
||||
MODELS[model] = module.load()
|
||||
return MODELS[model]
|
||||
|
||||
|
||||
def get_doc(vocab, words=[], pos=None, heads=None, deps=None, tags=None, ents=None):
|
||||
"""Create Doc object from given vocab, words and annotations."""
|
||||
pos = pos or [''] * len(words)
|
||||
|
|
Loading…
Reference in New Issue
Block a user