changed to input ids
Browse files- ref_seg_ger.py +8 -13
ref_seg_ger.py
CHANGED
|
@@ -214,30 +214,25 @@ class RefSeg(datasets.GeneratorBasedBuilder):
|
|
| 214 |
labels = []
|
| 215 |
for i, row in df.iterrows():
|
| 216 |
|
| 217 |
-
tokenized_input =
|
| 218 |
-
row['token'],
|
| 219 |
-
add_special_tokens=False,
|
| 220 |
-
return_offsets_mapping=False,
|
| 221 |
-
return_attention_mask=False,
|
| 222 |
-
)
|
| 223 |
#print(tokenized_input)
|
| 224 |
-
if len(tokenized_input
|
| 225 |
if row['tag'] == 'B':
|
| 226 |
-
input_ids.append(tokenized_input[
|
| 227 |
labels.append(row['tag'] + '-' + row['label'])
|
| 228 |
-
for input_id in tokenized_input[
|
| 229 |
input_ids.append(input_id)
|
| 230 |
labels.append('I-' + row['label'])
|
| 231 |
elif row['tag'] == 'I':
|
| 232 |
-
for input_id in tokenized_input
|
| 233 |
input_ids.append(input_id)
|
| 234 |
labels.append('I-' + row['label'])
|
| 235 |
else:
|
| 236 |
-
for input_id in tokenized_input
|
| 237 |
input_ids.append(input_id)
|
| 238 |
labels.append('O')
|
| 239 |
-
elif len(tokenized_input
|
| 240 |
-
input_ids.append(tokenized_input[
|
| 241 |
if row['tag'] == 'O':
|
| 242 |
labels.append(row['tag'])
|
| 243 |
else:
|
|
|
|
| 214 |
labels = []
|
| 215 |
for i, row in df.iterrows():
|
| 216 |
|
| 217 |
+
tokenized_input = row['token'].split(' ')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
#print(tokenized_input)
|
| 219 |
+
if len(tokenized_input) > 1:
|
| 220 |
if row['tag'] == 'B':
|
| 221 |
+
input_ids.append(tokenized_input[0])
|
| 222 |
labels.append(row['tag'] + '-' + row['label'])
|
| 223 |
+
for input_id in tokenized_input[1:]:
|
| 224 |
input_ids.append(input_id)
|
| 225 |
labels.append('I-' + row['label'])
|
| 226 |
elif row['tag'] == 'I':
|
| 227 |
+
for input_id in tokenized_input:
|
| 228 |
input_ids.append(input_id)
|
| 229 |
labels.append('I-' + row['label'])
|
| 230 |
else:
|
| 231 |
+
for input_id in tokenized_input:
|
| 232 |
input_ids.append(input_id)
|
| 233 |
labels.append('O')
|
| 234 |
+
elif len(tokenized_input) == 1:
|
| 235 |
+
input_ids.append(tokenized_input[0])
|
| 236 |
if row['tag'] == 'O':
|
| 237 |
labels.append(row['tag'])
|
| 238 |
else:
|