From 52f44dd6d23f5c1b3d550685c50281fa6ca12ff3 Mon Sep 17 00:00:00 2001 From: Bobby Donchev Date: Thu, 5 Nov 2020 15:38:30 +0100 Subject: [PATCH] change TokenClassificationTask class methods to static methods (#7902) * change TokenClassificationTask class methods to static methods Since we do not require self in the class methods of TokenClassificationTask we should probably switch to static methods. Also, since the class TokenClassificationTask does not contain a constructor it is currently unusable as is. By switching to static methods this fixes the issue of having to document the intent of the broken class. Also, since the get_labels and read_examples_from_file methods are ought to be implemented. Static method definitions are unchanged even after inheritance, which means that it can be overridden, similar to other class methods. * Trigger Build Co-authored-by: Lysandre --- examples/token-classification/utils_ner.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/token-classification/utils_ner.py b/examples/token-classification/utils_ner.py index 45c422927b..837d63002d 100644 --- a/examples/token-classification/utils_ner.py +++ b/examples/token-classification/utils_ner.py @@ -66,14 +66,16 @@ class Split(Enum): class TokenClassificationTask: - def read_examples_from_file(self, data_dir, mode: Union[Split, str]) -> List[InputExample]: + @staticmethod + def read_examples_from_file(data_dir, mode: Union[Split, str]) -> List[InputExample]: raise NotImplementedError - def get_labels(self, path: str) -> List[str]: + @staticmethod + def get_labels(path: str) -> List[str]: raise NotImplementedError + @staticmethod def convert_examples_to_features( - self, examples: List[InputExample], label_list: List[str], max_seq_length: int,