Felix
commited on
Commit
•
4fab6b9
1
Parent(s):
878d358
add _generate_examples method
Browse files- superlim-2.py +100 -1
superlim-2.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
import datasets
|
|
|
3 |
|
4 |
_CITATION = """\
|
5 |
"""
|
@@ -316,4 +317,102 @@ class SuperLim(datasets.GeneratorBasedBuilder):
|
|
316 |
"split": "test"
|
317 |
},
|
318 |
),
|
319 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import datasets
|
3 |
+
import pandas as pd
|
4 |
|
5 |
_CITATION = """\
|
6 |
"""
|
|
|
317 |
"split": "test"
|
318 |
},
|
319 |
),
|
320 |
+
]
|
321 |
+
|
322 |
+
def _generate_examples(self, filepath, split):
|
323 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
324 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
325 |
+
if self.config.name == 'swewic':
|
326 |
+
df = pd.read_json(filepath, lines=True)
|
327 |
+
else:
|
328 |
+
df = pd.read_csv(filepath, delimiter='\t')
|
329 |
+
for key, row in df.iterrows():
|
330 |
+
if self.config.name == "dalaj":
|
331 |
+
# Yields examples as (key, example) tuples
|
332 |
+
yield key, {
|
333 |
+
"original_sentence": row["original sentence"],
|
334 |
+
"corrected_sentence": row["corrected sentence"],
|
335 |
+
"error_indices": row["error indices"],
|
336 |
+
"corrected_indices": row["corrected indices"],
|
337 |
+
"error_corr_pair": row["error-corr pair"],
|
338 |
+
"error_label": row["error label"],
|
339 |
+
"l1": row["l1"],
|
340 |
+
"approximate_level": row["approximate level"],
|
341 |
+
}
|
342 |
+
elif self.config.name == "absabank":
|
343 |
+
yield key, {
|
344 |
+
"text": row["text"],
|
345 |
+
"label": row["label"],
|
346 |
+
}
|
347 |
+
elif self.config.name == "sweana":
|
348 |
+
yield key, {
|
349 |
+
"a": row["A"],
|
350 |
+
"b": row["B"],
|
351 |
+
"c": row["C"],
|
352 |
+
"d": row["D"],
|
353 |
+
"relation": row["relation"],
|
354 |
+
}
|
355 |
+
elif self.config.name == "swefaq":
|
356 |
+
yield key, {
|
357 |
+
"question": row["question"],
|
358 |
+
"candidate_answer": row["candidate_answer"],
|
359 |
+
"correct_answer": row["correct_answer"],
|
360 |
+
}
|
361 |
+
elif self.config.name == "swepar":
|
362 |
+
yield key, {
|
363 |
+
"sentence_1": row["sentence_1"],
|
364 |
+
"sentence_2": row["sentence_2"],
|
365 |
+
"similarity_score": row["similarity_score"],
|
366 |
+
}
|
367 |
+
elif self.config.name == "swesat":
|
368 |
+
yield key, {
|
369 |
+
"target_item": row["target_item"],
|
370 |
+
"answer_1": row["answer_1"],
|
371 |
+
"answer_2": row["answer_2"],
|
372 |
+
"answer_3": row["answer_3"],
|
373 |
+
"answer_4": row["answer_4"],
|
374 |
+
"answer_5": row["answer_5"],
|
375 |
+
}
|
376 |
+
elif self.config.name == "swesim_relatedness":
|
377 |
+
yield key, {
|
378 |
+
"word_1": row["Word 1 "],
|
379 |
+
"word_2": row[" Word 2 "],
|
380 |
+
"relatedness": row[" Average "],
|
381 |
+
}
|
382 |
+
elif self.config.name == "swesim_similarity":
|
383 |
+
yield key, {
|
384 |
+
"word_1": row["Word 1 "],
|
385 |
+
"word_2": row[" Word 2 "],
|
386 |
+
"similarity": row[" Average "],
|
387 |
+
}
|
388 |
+
elif self.config.name == "swewgr":
|
389 |
+
yield key, {
|
390 |
+
"text": row["text"],
|
391 |
+
"challenge": row["challenge"],
|
392 |
+
"responses": row["responses"],
|
393 |
+
}
|
394 |
+
elif self.config.name == "swewic":
|
395 |
+
yield key, {
|
396 |
+
"sentence_1": row["sentence1"],
|
397 |
+
"word_1": row["word1"],
|
398 |
+
"sentence_2": row["sentence2"],
|
399 |
+
"word_2": row["word2"],
|
400 |
+
"same_sense": row["same_sense"],
|
401 |
+
"start_1": row["start1"],
|
402 |
+
"end_1": row["end1"],
|
403 |
+
"start_2": row["start2"],
|
404 |
+
"end_2": row["end2"],
|
405 |
+
}
|
406 |
+
elif self.config.name == "swewsc":
|
407 |
+
yield key, {
|
408 |
+
"passage": row["passage"],
|
409 |
+
"challenge_text": row["challenge_text"],
|
410 |
+
"response_text": row["response_text"],
|
411 |
+
"challenge_begin":row["challenge_begin"],
|
412 |
+
"challenge_end":row["challenge_end"],
|
413 |
+
"response_begin":row["response_begin"],
|
414 |
+
"response_end":row["response_end"],
|
415 |
+
"label":row["label"]
|
416 |
+
}
|
417 |
+
else:
|
418 |
+
raise ValueError(f"Subset {self.config.name} does not exist")
|