mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-24 00:04:15 +03:00
remove redundant __call__ method in pipes.TextCategorizer (#4305)
* remove redundant __call__ method in pipes.TextCategorizer Because the parent __call__ method behaves in the same way. * fix: Pipe.__call__ arg * fix: invalid arg in Pipe.__call__ * modified: spacy/tests/regression/test_issue4278.py (#4278) * deleted: Pipfile
This commit is contained in:
parent
ee15fdfe88
commit
875f3e5d8c
|
@ -69,7 +69,7 @@ class Pipe(object):
|
||||||
predictions = self.predict([doc])
|
predictions = self.predict([doc])
|
||||||
if isinstance(predictions, tuple) and len(predictions) == 2:
|
if isinstance(predictions, tuple) and len(predictions) == 2:
|
||||||
scores, tensors = predictions
|
scores, tensors = predictions
|
||||||
self.set_annotations([doc], scores, tensor=tensors)
|
self.set_annotations([doc], scores, tensors=tensors)
|
||||||
else:
|
else:
|
||||||
self.set_annotations([doc], predictions)
|
self.set_annotations([doc], predictions)
|
||||||
return doc
|
return doc
|
||||||
|
@ -90,7 +90,7 @@ class Pipe(object):
|
||||||
predictions = self.predict(docs)
|
predictions = self.predict(docs)
|
||||||
if isinstance(predictions, tuple) and len(tuple) == 2:
|
if isinstance(predictions, tuple) and len(tuple) == 2:
|
||||||
scores, tensors = predictions
|
scores, tensors = predictions
|
||||||
self.set_annotations(docs, scores, tensor=tensors)
|
self.set_annotations(docs, scores, tensors=tensors)
|
||||||
else:
|
else:
|
||||||
self.set_annotations(docs, predictions)
|
self.set_annotations(docs, predictions)
|
||||||
yield from docs
|
yield from docs
|
||||||
|
@ -932,11 +932,6 @@ class TextCategorizer(Pipe):
|
||||||
def labels(self, value):
|
def labels(self, value):
|
||||||
self.cfg["labels"] = tuple(value)
|
self.cfg["labels"] = tuple(value)
|
||||||
|
|
||||||
def __call__(self, doc):
|
|
||||||
scores, tensors = self.predict([doc])
|
|
||||||
self.set_annotations([doc], scores, tensors=tensors)
|
|
||||||
return doc
|
|
||||||
|
|
||||||
def pipe(self, stream, batch_size=128, n_threads=-1):
|
def pipe(self, stream, batch_size=128, n_threads=-1):
|
||||||
for docs in util.minibatch(stream, size=batch_size):
|
for docs in util.minibatch(stream, size=batch_size):
|
||||||
docs = list(docs)
|
docs = list(docs)
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DummyPipe(Pipe):
|
||||||
def predict(self, docs):
|
def predict(self, docs):
|
||||||
return ([1, 2, 3], [4, 5, 6])
|
return ([1, 2, 3], [4, 5, 6])
|
||||||
|
|
||||||
def set_annotations(self, docs, scores, tensor=None):
|
def set_annotations(self, docs, scores, tensors=None):
|
||||||
return docs
|
return docs
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user