fix none subword label
Browse files- iwslt2011.py +13 -8
iwslt2011.py
CHANGED
@@ -102,7 +102,7 @@ class IWSLT11Config(datasets.BuilderConfig):
|
|
102 |
asr_or_ref: str = "ref",
|
103 |
decoder: DecodingStrategy = AverageDecodingStrategy(),
|
104 |
tokenizer = None,
|
105 |
-
label_subword
|
106 |
**kwargs
|
107 |
):
|
108 |
"""BuilderConfig for IWSLT2011.
|
@@ -120,14 +120,8 @@ class IWSLT11Config(datasets.BuilderConfig):
|
|
120 |
Punctuation.PERIOD,
|
121 |
Punctuation.COMMA,
|
122 |
Punctuation.QUESTION,
|
|
|
123 |
]
|
124 |
-
if isinstance(label_subword, str):
|
125 |
-
if 'ignore' == label_subword.lower():
|
126 |
-
label_subword = LabelSubword.IGNORE
|
127 |
-
if 'none' == label_subword.lower():
|
128 |
-
label_subword = LabelSubword.NONE
|
129 |
-
if label_subword.IGNORE:
|
130 |
-
self.punctuation.append(label_subword.IGNORE)
|
131 |
self.label_subword = label_subword
|
132 |
self.tokenizer = tokenizer
|
133 |
super(IWSLT11Config, self).__init__(**kwargs)
|
@@ -144,6 +138,17 @@ class IWSLT11(datasets.GeneratorBasedBuilder):
|
|
144 |
IWSLT11Config(name="asr", asr_or_ref="asr"),
|
145 |
]
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
def _info(self):
|
148 |
if self.config.task == Task.TAGGING:
|
149 |
return datasets.DatasetInfo(
|
|
|
102 |
asr_or_ref: str = "ref",
|
103 |
decoder: DecodingStrategy = AverageDecodingStrategy(),
|
104 |
tokenizer = None,
|
105 |
+
label_subword = LabelSubword.IGNORE,
|
106 |
**kwargs
|
107 |
):
|
108 |
"""BuilderConfig for IWSLT2011.
|
|
|
120 |
Punctuation.PERIOD,
|
121 |
Punctuation.COMMA,
|
122 |
Punctuation.QUESTION,
|
123 |
+
label_subword.IGNORE
|
124 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
self.label_subword = label_subword
|
126 |
self.tokenizer = tokenizer
|
127 |
super(IWSLT11Config, self).__init__(**kwargs)
|
|
|
138 |
IWSLT11Config(name="asr", asr_or_ref="asr"),
|
139 |
]
|
140 |
|
141 |
+
def __init__(self, *args, **kwargs):
|
142 |
+
if 'label_subword' in kwargs:
|
143 |
+
label_subword = kwargs['label_subword']
|
144 |
+
if isinstance(label_subword, str):
|
145 |
+
if 'ignore' == label_subword.lower():
|
146 |
+
label_subword = LabelSubword.IGNORE
|
147 |
+
if 'none' == label_subword.lower():
|
148 |
+
label_subword = LabelSubword.NONE
|
149 |
+
kwargs['label_subword'] = label_subword
|
150 |
+
super(IWSLT11, self).__init__(*args, **kwargs)
|
151 |
+
|
152 |
def _info(self):
|
153 |
if self.config.task == Task.TAGGING:
|
154 |
return datasets.DatasetInfo(
|