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:
ines 2017-05-29 22:11:31 +02:00
parent ad3c8b3ad9
commit 795fe43a4d

View File

@ -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)