mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
* Silently don't parse if data is not present
This commit is contained in:
parent
0d62236247
commit
951d06c824
|
@ -84,6 +84,9 @@ class English(object):
|
|||
self._tagger = None
|
||||
self._parser = None
|
||||
|
||||
self.has_parser_model = path.exists(path.join(self._data_dir, 'deps'))
|
||||
self.has_tagger_model = path.exists(path.join(self._data_dir, 'pos'))
|
||||
|
||||
@property
|
||||
def tagger(self):
|
||||
if self._tagger is None:
|
||||
|
@ -112,9 +115,9 @@ class English(object):
|
|||
tokens (spacy.tokens.Tokens):
|
||||
"""
|
||||
tokens = self.tokenizer(text)
|
||||
if tag or parse:
|
||||
if tag or parse and self.has_tagger_model:
|
||||
self.tagger(tokens)
|
||||
if parse:
|
||||
if parse and self.has_parser_model:
|
||||
self.parser(tokens)
|
||||
return tokens
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user