mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 04:08:09 +03:00
Fix issue #535: Pipeline elements added even when data not installed.
This commit is contained in:
parent
ca89fd0919
commit
d4aaf2752c
|
@ -70,8 +70,10 @@ class BaseDefaults(object):
|
|||
def create_tagger(cls, nlp=None):
|
||||
if nlp is None:
|
||||
return Tagger(cls.create_vocab(), features=cls.tagger_features)
|
||||
elif nlp.path is None or not (nlp.path / 'pos').exists():
|
||||
elif nlp.path is None:
|
||||
return Tagger(nlp.vocab, features=cls.tagger_features)
|
||||
elif not (nlp.path / 'pos').exists():
|
||||
return None
|
||||
else:
|
||||
return Tagger.load(nlp.path / 'pos', nlp.vocab)
|
||||
|
||||
|
@ -79,8 +81,10 @@ class BaseDefaults(object):
|
|||
def create_parser(cls, nlp=None):
|
||||
if nlp is None:
|
||||
return DependencyParser(cls.create_vocab(), features=cls.parser_features)
|
||||
elif nlp.path is None or not (nlp.path / 'deps').exists():
|
||||
elif nlp.path is None:
|
||||
return DependencyParser(nlp.vocab, features=cls.parser_features)
|
||||
elif not (nlp.path / 'deps').exists():
|
||||
return None
|
||||
else:
|
||||
return DependencyParser.load(nlp.path / 'deps', nlp.vocab)
|
||||
|
||||
|
@ -88,8 +92,10 @@ class BaseDefaults(object):
|
|||
def create_entity(cls, nlp=None):
|
||||
if nlp is None:
|
||||
return EntityRecognizer(cls.create_vocab(), features=cls.entity_features)
|
||||
elif nlp.path is None or not (nlp.path / 'ner').exists():
|
||||
elif nlp.path is None:
|
||||
return EntityRecognizer(nlp.vocab, features=cls.entity_features)
|
||||
elif not (nlp.path / 'ner').exists():
|
||||
return None
|
||||
else:
|
||||
return EntityRecognizer.load(nlp.path / 'ner', nlp.vocab)
|
||||
|
||||
|
@ -97,8 +103,10 @@ class BaseDefaults(object):
|
|||
def create_matcher(cls, nlp=None):
|
||||
if nlp is None:
|
||||
return Matcher(cls.create_vocab())
|
||||
elif nlp.path is None or not (nlp.path / 'vocab').exists():
|
||||
elif nlp.path is None:
|
||||
return Matcher(nlp.vocab)
|
||||
elif not (nlp.path / 'vocab').exists():
|
||||
return None
|
||||
else:
|
||||
return Matcher.load(nlp.path / 'vocab', nlp.vocab)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user