The previous commits broke PROPOR2024, now it is fixed
Browse files- aes_enem_dataset.py +44 -21
aes_enem_dataset.py
CHANGED
@@ -81,6 +81,15 @@ CSV_HEADER = [
|
|
81 |
"essay_year",
|
82 |
]
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
SOURCE_A_DESC = """
|
85 |
Source A have 860 essays available from August 2015 to March 2020.
|
86 |
For each month of that period, a new prompt together with supporting texts were given, and the graded essays from the previous month were made available.
|
@@ -405,27 +414,41 @@ class AesEnemDataset(datasets.GeneratorBasedBuilder):
|
|
405 |
|
406 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
407 |
def _generate_examples(self, filepath, split):
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
grades = grades.
|
415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
grades = grades.split(", ")
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
|
|
429 |
|
430 |
|
431 |
class HTMLParser:
|
@@ -596,7 +619,7 @@ class HTMLParser:
|
|
596 |
span.decompose()
|
597 |
result = table.find_all("p")
|
598 |
result = " ".join(
|
599 |
-
[paragraph.get_text().strip() for paragraph in result]
|
600 |
)
|
601 |
return result
|
602 |
|
|
|
81 |
"essay_year",
|
82 |
]
|
83 |
|
84 |
+
CSV_HEADERPROPOR = [
|
85 |
+
"id",
|
86 |
+
"id_prompt",
|
87 |
+
"title",
|
88 |
+
"essay",
|
89 |
+
"grades",
|
90 |
+
"essay_year",
|
91 |
+
]
|
92 |
+
|
93 |
SOURCE_A_DESC = """
|
94 |
Source A have 860 essays available from August 2015 to March 2020.
|
95 |
For each month of that period, a new prompt together with supporting texts were given, and the graded essays from the previous month were made available.
|
|
|
414 |
|
415 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
416 |
def _generate_examples(self, filepath, split):
|
417 |
+
if self.config.name == "PROPOR2024":
|
418 |
+
with open(filepath, encoding="utf-8") as csvfile:
|
419 |
+
next(csvfile)
|
420 |
+
csv_reader = csv.DictReader(csvfile, fieldnames=CSV_HEADERPROPOR)
|
421 |
+
for i, row in enumerate(csv_reader):
|
422 |
+
grades = row["grades"].strip("[]")
|
423 |
+
grades = grades.split()
|
424 |
+
yield i, {
|
425 |
+
"id": row["id"],
|
426 |
+
"id_prompt": row["id_prompt"],
|
427 |
+
"essay_title": row["title"],
|
428 |
+
"essay_text": row["essay"],
|
429 |
+
"grades": grades,
|
430 |
+
"essay_year": row["essay_year"],
|
431 |
+
}
|
432 |
+
else:
|
433 |
+
with open(filepath, encoding="utf-8") as csvfile:
|
434 |
+
next(csvfile)
|
435 |
+
csv_reader = csv.DictReader(csvfile, fieldnames=CSV_HEADER)
|
436 |
+
for i, row in enumerate(csv_reader):
|
437 |
+
grades = row["grades"].strip("[]")
|
438 |
grades = grades.split(", ")
|
439 |
+
yield i, {
|
440 |
+
"id": row["id"],
|
441 |
+
"id_prompt": row["id_prompt"],
|
442 |
+
"prompt": row['prompt'],
|
443 |
+
"supporting_text": row["supporting_text"],
|
444 |
+
"essay_title": row["title"],
|
445 |
+
"essay_text": row["essay"],
|
446 |
+
"grades": grades,
|
447 |
+
"essay_year": row["essay_year"],
|
448 |
+
"general_comment": row["general"],
|
449 |
+
"specific_comment": row["specific"],
|
450 |
+
}
|
451 |
+
|
452 |
|
453 |
|
454 |
class HTMLParser:
|
|
|
619 |
span.decompose()
|
620 |
result = table.find_all("p")
|
621 |
result = " ".join(
|
622 |
+
[paragraph.get_text().replace("\xa0","").strip() for paragraph in result]
|
623 |
)
|
624 |
return result
|
625 |
|