spaCy/spacy/__init__.py

32 lines
748 B
Python
Raw Normal View History

import pathlib
from .util import set_lang_class, get_lang_class
from . import en
from . import de
from . import zh
2016-09-24 20:09:21 +00:00
try:
2016-09-24 20:17:01 +00:00
basestring
2016-09-24 20:09:21 +00:00
except NameError:
2016-09-24 20:17:01 +00:00
basestring = str
2016-09-24 20:09:21 +00:00
set_lang_class(en.English.lang, en.English)
set_lang_class(de.German.lang, de.German)
set_lang_class(zh.Chinese.lang, zh.Chinese)
2016-03-25 17:54:45 +00:00
2016-10-18 17:23:31 +00:00
def load(name, **overrides):
target_name, target_version = util.split_data_name(name)
2016-10-18 17:23:31 +00:00
path = overrides.get('path', util.get_data_path())
path = util.match_best_version(target_name, target_version, path)
2016-10-18 17:23:31 +00:00
if isinstance(overrides.get('vectors'), basestring):
vectors = util.match_best_version(overrides.get('vectors'), None, path)
2016-09-24 18:26:17 +00:00
cls = get_lang_class(target_name)
2016-10-18 17:23:31 +00:00
return cls(path=path, **overrides)