mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Fix __call__ method
This commit is contained in:
parent
5cf47b847b
commit
bc97bc292c
|
@ -192,7 +192,7 @@ class Language(object):
|
|||
name = getattr(proc, 'name', None)
|
||||
if name in disable:
|
||||
continue
|
||||
proc(doc)
|
||||
doc = proc(doc)
|
||||
return doc
|
||||
|
||||
def update(self, docs, golds, drop=0., sgd=None, losses=None):
|
||||
|
|
|
@ -73,17 +73,16 @@ class TokenVectorEncoder(object):
|
|||
self.doc2feats = doc2feats()
|
||||
self.model = model
|
||||
|
||||
def __call__(self, docs):
|
||||
def __call__(self, doc):
|
||||
"""Add context-sensitive vectors to a `Doc`, e.g. from a CNN or LSTM
|
||||
model. Vectors are set to the `Doc.tensor` attribute.
|
||||
|
||||
docs (Doc or iterable): One or more documents to add vectors to.
|
||||
RETURNS (dict or None): Intermediate computations.
|
||||
"""
|
||||
if isinstance(docs, Doc):
|
||||
docs = [docs]
|
||||
tokvecses = self.predict(docs)
|
||||
self.set_annotations(docs, tokvecses)
|
||||
tokvecses = self.predict([doc])
|
||||
self.set_annotations([doc], tokvecses)
|
||||
return doc
|
||||
|
||||
def pipe(self, stream, batch_size=128, n_threads=-1):
|
||||
"""Process `Doc` objects as a stream.
|
||||
|
@ -169,6 +168,7 @@ class NeuralTagger(object):
|
|||
def __call__(self, doc):
|
||||
tags = self.predict([doc.tensor])
|
||||
self.set_annotations([doc], tags)
|
||||
return doc
|
||||
|
||||
def pipe(self, stream, batch_size=128, n_threads=-1):
|
||||
for docs in cytoolz.partition_all(batch_size, stream):
|
||||
|
|
|
@ -305,8 +305,9 @@ cdef class Parser:
|
|||
Returns:
|
||||
None
|
||||
"""
|
||||
states = self.parse_batch([doc], doc.tensor)
|
||||
self.set_annotations(doc, states[0])
|
||||
states = self.parse_batch([doc], [doc.tensor])
|
||||
self.set_annotations([doc], states)
|
||||
return doc
|
||||
|
||||
def pipe(self, docs, int batch_size=1000, int n_threads=2):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user