mirror of https://github.com/explosion/spaCy.git
Python 3 compatible basestring
This commit is contained in:
parent
f19af6cb2c
commit
082e95b19e
|
@ -7,13 +7,20 @@ from . import de
|
||||||
from . import zh
|
from . import zh
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
basestring
|
||||||
|
except NameError:
|
||||||
|
basestring = str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set_lang_class(en.English.lang, en.English)
|
set_lang_class(en.English.lang, en.English)
|
||||||
set_lang_class(de.German.lang, de.German)
|
set_lang_class(de.German.lang, de.German)
|
||||||
set_lang_class(zh.Chinese.lang, zh.Chinese)
|
set_lang_class(zh.Chinese.lang, zh.Chinese)
|
||||||
|
|
||||||
|
|
||||||
def load(name, vocab=True, tokenizer=True, parser=True, tagger=True, entity=True,
|
def load(name, vocab=True, tokenizer=True, parser=True, tagger=True, entity=True,
|
||||||
matcher=True, serializer=True, vectors=True, via=None):
|
matcher=True, serializer=True, vectors=True, pipeline=True, via=None):
|
||||||
if via is None:
|
if via is None:
|
||||||
via = util.get_data_path()
|
via = util.get_data_path()
|
||||||
|
|
||||||
|
@ -21,8 +28,7 @@ def load(name, vocab=True, tokenizer=True, parser=True, tagger=True, entity=True
|
||||||
path = util.match_best_version(target_name, target_version, via)
|
path = util.match_best_version(target_name, target_version, via)
|
||||||
|
|
||||||
if isinstance(vectors, basestring):
|
if isinstance(vectors, basestring):
|
||||||
vectors_name, vectors_version = util.split_data_name(vectors)
|
vectors = util.match_best_version(vectors, None, via)
|
||||||
vectors = util.match_best_version(vectors_name, vectors_version, via)
|
|
||||||
|
|
||||||
cls = get_lang_class(target_name)
|
cls = get_lang_class(target_name)
|
||||||
return cls(
|
return cls(
|
||||||
|
@ -34,4 +40,5 @@ def load(name, vocab=True, tokenizer=True, parser=True, tagger=True, entity=True
|
||||||
parser=parser,
|
parser=parser,
|
||||||
entity=entity,
|
entity=entity,
|
||||||
matcher=matcher,
|
matcher=matcher,
|
||||||
|
pipeline=pipeline,
|
||||||
serializer=serializer)
|
serializer=serializer)
|
||||||
|
|
Loading…
Reference in New Issue