Skip to content

Commit 52f44dd

Browse files
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>
1 parent 77c8f6c commit 52f44dd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/token-classification/utils_ner.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ class Split(Enum):
6666

6767

6868
class TokenClassificationTask:
69-
def read_examples_from_file(self, data_dir, mode: Union[Split, str]) -> List[InputExample]:
69+
@staticmethod
70+
def read_examples_from_file(data_dir, mode: Union[Split, str]) -> List[InputExample]:
7071
raise NotImplementedError
7172

72-
def get_labels(self, path: str) -> List[str]:
73+
@staticmethod
74+
def get_labels(path: str) -> List[str]:
7375
raise NotImplementedError
7476

77+
@staticmethod
7578
def convert_examples_to_features(
76-
self,
7779
examples: List[InputExample],
7880
label_list: List[str],
7981
max_seq_length: int,

0 commit comments

Comments
 (0)