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 <lysandre.debut@reseau.eseo.fr>
This commit is contained in:
Bobby Donchev
2020-11-05 15:38:30 +01:00
committed by GitHub
parent 77c8f6c627
commit 52f44dd6d2

View File

@@ -66,14 +66,16 @@ class Split(Enum):
class TokenClassificationTask: 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 raise NotImplementedError
def get_labels(self, path: str) -> List[str]: @staticmethod
def get_labels(path: str) -> List[str]:
raise NotImplementedError raise NotImplementedError
@staticmethod
def convert_examples_to_features( def convert_examples_to_features(
self,
examples: List[InputExample], examples: List[InputExample],
label_list: List[str], label_list: List[str],
max_seq_length: int, max_seq_length: int,