igorcs commited on
Commit
ab290d0
1 Parent(s): c1daf1d

The previous commits broke PROPOR2024, now it is fixed

Browse files
Files changed (1) hide show
  1. 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
- with open(filepath, encoding="utf-8") as csvfile:
409
- next(csvfile)
410
- csv_reader = csv.DictReader(csvfile, fieldnames=CSV_HEADER)
411
- for i, row in enumerate(csv_reader):
412
- grades = row["grades"].strip("[]")
413
- if self.config.name == "PROPOR2024":
414
- grades = grades.strip().split()
415
- else:
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  grades = grades.split(", ")
417
- yield i, {
418
- "id": row["id"],
419
- "id_prompt": row["id_prompt"],
420
- "prompt": row['prompt'],
421
- "supporting_text": row["supporting_text"],
422
- "essay_title": row["title"],
423
- "essay_text": row["essay"],
424
- "grades": grades,
425
- "essay_year": row["essay_year"],
426
- "general_comment": row["general"],
427
- "specific_comment": row["specific"],
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