holylovenia commited on
Commit
25ea5b4
1 Parent(s): 85ed762

Upload facqa.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. facqa.py +14 -13
facqa.py CHANGED
@@ -5,10 +5,10 @@ from typing import Dict, List, Tuple
5
  import datasets
6
  import pandas as pd
7
 
8
- from nusacrowd.nusa_datasets.facqa.utils.facqa_utils import (getAnswerString, listToString)
9
- from nusacrowd.utils import schemas
10
- from nusacrowd.utils.configs import NusantaraConfig
11
- from nusacrowd.utils.constants import Tasks
12
 
13
  _CITATION = """
14
  @inproceedings{purwarianti2007machine,
@@ -48,28 +48,28 @@ _SUPPORTED_TASKS = [Tasks.QUESTION_ANSWERING]
48
 
49
  _SOURCE_VERSION = "1.0.0"
50
 
51
- _NUSANTARA_VERSION = "1.0.0"
52
 
53
 
54
  class FacqaDataset(datasets.GeneratorBasedBuilder):
55
  """FacQA dataset is a labeled dataset for indonesian question answering task"""
56
 
57
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
58
- NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
59
 
60
  BUILDER_CONFIGS = [
61
- NusantaraConfig(
62
  name="facqa_source",
63
  version=SOURCE_VERSION,
64
  description="FacQA source schema",
65
  schema="source",
66
  subset_id="facqa",
67
  ),
68
- NusantaraConfig(
69
- name="facqa_nusantara_qa",
70
- version=NUSANTARA_VERSION,
71
  description="FacQA Nusantara schema",
72
- schema="nusantara_qa",
73
  subset_id="facqa",
74
  ),
75
  ]
@@ -86,7 +86,7 @@ class FacqaDataset(datasets.GeneratorBasedBuilder):
86
  "seq_label": [datasets.Value("string")],
87
  }
88
  )
89
- elif self.config.schema == "nusantara_qa":
90
  features = schemas.qa_features
91
 
92
  return datasets.DatasetInfo(
@@ -140,7 +140,7 @@ class FacqaDataset(datasets.GeneratorBasedBuilder):
140
  entry = {"index": row.index, "question": ast.literal_eval(row.question), "passage": ast.literal_eval(row.passage), "seq_label": ast.literal_eval(row.seq_label)}
141
  yield row.index, entry
142
 
143
- elif self.config.schema == "nusantara_qa":
144
  for row in df.itertuples():
145
  entry = {
146
  "id": str(row.index),
@@ -151,5 +151,6 @@ class FacqaDataset(datasets.GeneratorBasedBuilder):
151
  "choices": [],
152
  "context": listToString(ast.literal_eval(row.passage)),
153
  "answer": [getAnswerString(ast.literal_eval(row.passage), ast.literal_eval(row.seq_label))],
 
154
  }
155
  yield row.index, entry
 
5
  import datasets
6
  import pandas as pd
7
 
8
+ from seacrowd.sea_datasets.facqa.utils.facqa_utils import (getAnswerString, listToString)
9
+ from seacrowd.utils import schemas
10
+ from seacrowd.utils.configs import SEACrowdConfig
11
+ from seacrowd.utils.constants import Tasks
12
 
13
  _CITATION = """
14
  @inproceedings{purwarianti2007machine,
 
48
 
49
  _SOURCE_VERSION = "1.0.0"
50
 
51
+ _SEACROWD_VERSION = "2024.06.20"
52
 
53
 
54
  class FacqaDataset(datasets.GeneratorBasedBuilder):
55
  """FacQA dataset is a labeled dataset for indonesian question answering task"""
56
 
57
  SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
58
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
59
 
60
  BUILDER_CONFIGS = [
61
+ SEACrowdConfig(
62
  name="facqa_source",
63
  version=SOURCE_VERSION,
64
  description="FacQA source schema",
65
  schema="source",
66
  subset_id="facqa",
67
  ),
68
+ SEACrowdConfig(
69
+ name="facqa_seacrowd_qa",
70
+ version=SEACROWD_VERSION,
71
  description="FacQA Nusantara schema",
72
+ schema="seacrowd_qa",
73
  subset_id="facqa",
74
  ),
75
  ]
 
86
  "seq_label": [datasets.Value("string")],
87
  }
88
  )
89
+ elif self.config.schema == "seacrowd_qa":
90
  features = schemas.qa_features
91
 
92
  return datasets.DatasetInfo(
 
140
  entry = {"index": row.index, "question": ast.literal_eval(row.question), "passage": ast.literal_eval(row.passage), "seq_label": ast.literal_eval(row.seq_label)}
141
  yield row.index, entry
142
 
143
+ elif self.config.schema == "seacrowd_qa":
144
  for row in df.itertuples():
145
  entry = {
146
  "id": str(row.index),
 
151
  "choices": [],
152
  "context": listToString(ast.literal_eval(row.passage)),
153
  "answer": [getAnswerString(ast.literal_eval(row.passage), ast.literal_eval(row.seq_label))],
154
+ "meta": {}
155
  }
156
  yield row.index, entry