mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
* Add Language.batch() method, to support multi-threaded jobs
This commit is contained in:
parent
b3802562d6
commit
98fbdf2856
|
@ -269,6 +269,17 @@ class Language(object):
|
|||
self.entity(tokens)
|
||||
return tokens
|
||||
|
||||
def batch(self, texts, tag=True, parse=True, entity=True):
|
||||
if tag is False:
|
||||
return [self(text, tag=tag, parse=parse, entity=entity)
|
||||
for text in texts]
|
||||
docs = []
|
||||
for text in texts:
|
||||
doc = self(text, tag=True, parse=False, entity=entity)
|
||||
if self.parser and parse:
|
||||
self.parser.parse_batch(docs)
|
||||
return docs
|
||||
|
||||
def end_training(self, data_dir=None):
|
||||
if data_dir is None:
|
||||
data_dir = self.data_dir
|
||||
|
|
Loading…
Reference in New Issue
Block a user