From 875f3e5d8c09738d9abe42c2d3d952ba5b6870b0 Mon Sep 17 00:00:00 2001 From: tamuhey Date: Thu, 19 Sep 2019 04:31:27 +0900 Subject: [PATCH] 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 --- spacy/pipeline/pipes.pyx | 9 ++------- spacy/tests/regression/test_issue4278.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/spacy/pipeline/pipes.pyx b/spacy/pipeline/pipes.pyx index 190116a2e..2ca1801c9 100644 --- a/spacy/pipeline/pipes.pyx +++ b/spacy/pipeline/pipes.pyx @@ -69,7 +69,7 @@ class Pipe(object): predictions = self.predict([doc]) if isinstance(predictions, tuple) and len(predictions) == 2: scores, tensors = predictions - self.set_annotations([doc], scores, tensor=tensors) + self.set_annotations([doc], scores, tensors=tensors) else: self.set_annotations([doc], predictions) return doc @@ -90,7 +90,7 @@ class Pipe(object): predictions = self.predict(docs) if isinstance(predictions, tuple) and len(tuple) == 2: scores, tensors = predictions - self.set_annotations(docs, scores, tensor=tensors) + self.set_annotations(docs, scores, tensors=tensors) else: self.set_annotations(docs, predictions) yield from docs @@ -932,11 +932,6 @@ class TextCategorizer(Pipe): def labels(self, 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): for docs in util.minibatch(stream, size=batch_size): docs = list(docs) diff --git a/spacy/tests/regression/test_issue4278.py b/spacy/tests/regression/test_issue4278.py index 4c85d15c4..cb09340ff 100644 --- a/spacy/tests/regression/test_issue4278.py +++ b/spacy/tests/regression/test_issue4278.py @@ -13,7 +13,7 @@ class DummyPipe(Pipe): def predict(self, docs): 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