From 8c2652d788fc38501490beb5826dd4c271fbfba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= Date: Mon, 29 Aug 2022 16:47:13 +0200 Subject: [PATCH] Remove `TrainablePipe.activations` We do not need to enumerate the activations anymore since `store_activations` is `bool`. --- spacy/pipeline/edit_tree_lemmatizer.py | 4 ---- spacy/pipeline/entity_linker.py | 4 ---- spacy/pipeline/senter.pyx | 4 ---- spacy/pipeline/spancat.py | 4 ---- spacy/pipeline/tagger.pyx | 6 +----- spacy/pipeline/textcat.py | 4 ---- spacy/pipeline/trainable_pipe.pyx | 4 ---- spacy/pipeline/transition_parser.pyx | 8 +------- 8 files changed, 2 insertions(+), 36 deletions(-) diff --git a/spacy/pipeline/edit_tree_lemmatizer.py b/spacy/pipeline/edit_tree_lemmatizer.py index f97ff875f..d94e8981b 100644 --- a/spacy/pipeline/edit_tree_lemmatizer.py +++ b/spacy/pipeline/edit_tree_lemmatizer.py @@ -394,7 +394,3 @@ class EditTreeLemmatizer(TrainablePipe): self.tree2label[tree_id] = len(self.cfg["labels"]) self.cfg["labels"].append(tree_id) return self.tree2label[tree_id] - - @property - def activations(self): - return ["probs", "guesses"] diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index f6aca2487..17680b95d 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -656,10 +656,6 @@ class EntityLinker(TrainablePipe): def add_label(self, label): raise NotImplementedError - @property - def activations(self): - return ["ents", "scores"] - def _add_doc_activations( self, *, diff --git a/spacy/pipeline/senter.pyx b/spacy/pipeline/senter.pyx index 499f2866d..b8916fc69 100644 --- a/spacy/pipeline/senter.pyx +++ b/spacy/pipeline/senter.pyx @@ -205,7 +205,3 @@ class SentenceRecognizer(Tagger): def add_label(self, label, values=None): raise NotImplementedError - - @property - def activations(self): - return ["probs", "guesses"] diff --git a/spacy/pipeline/spancat.py b/spacy/pipeline/spancat.py index 2179c3c23..042c68e36 100644 --- a/spacy/pipeline/spancat.py +++ b/spacy/pipeline/spancat.py @@ -493,7 +493,3 @@ class SpanCategorizer(TrainablePipe): spans.append(Span(doc, start, end, label=labels[j])) return spans - - @property - def activations(self): - return ["indices", "scores"] diff --git a/spacy/pipeline/tagger.pyx b/spacy/pipeline/tagger.pyx index 13513f6de..a1fe3be72 100644 --- a/spacy/pipeline/tagger.pyx +++ b/spacy/pipeline/tagger.pyx @@ -338,8 +338,4 @@ class Tagger(TrainablePipe): self._allow_extra_label() self.cfg["labels"].append(label) self.vocab.strings.add(label) - return 1 - - @property - def activations(self): - return ["probs", "guesses"] + return 1 \ No newline at end of file diff --git a/spacy/pipeline/textcat.py b/spacy/pipeline/textcat.py index 7789c88bb..acb8be406 100644 --- a/spacy/pipeline/textcat.py +++ b/spacy/pipeline/textcat.py @@ -416,7 +416,3 @@ class TextCategorizer(TrainablePipe): for ex in examples: if list(ex.reference.cats.values()).count(1.0) > 1: raise ValueError(Errors.E895.format(value=ex.reference.cats)) - - @property - def activations(self): - return ["probs"] diff --git a/spacy/pipeline/trainable_pipe.pyx b/spacy/pipeline/trainable_pipe.pyx index 2bd081b07..a21cea33b 100644 --- a/spacy/pipeline/trainable_pipe.pyx +++ b/spacy/pipeline/trainable_pipe.pyx @@ -344,10 +344,6 @@ cdef class TrainablePipe(Pipe): util.from_disk(path, deserialize, exclude) return self - @property - def activations(self): - raise NotImplementedError(Errors.E931.format(parent="TrainablePipe", method="activations", name=self.name)) - @property def store_activations(self): return self._store_activations diff --git a/spacy/pipeline/transition_parser.pyx b/spacy/pipeline/transition_parser.pyx index b2611854c..2af59f01d 100644 --- a/spacy/pipeline/transition_parser.pyx +++ b/spacy/pipeline/transition_parser.pyx @@ -665,10 +665,4 @@ cdef class Parser(TrainablePipe): golds.append(gold) if state.is_final(): break - return states, golds, max_length - - @property - def activations(self): - # We currently do not have access to the state ids or probabilities - # after parsing. TODO: the parser refactor does provide some history. - return [] + return states, golds, max_length \ No newline at end of file