small refactor

#1
by davanstrien HF staff - opened
Files changed (1) hide show
  1. contentious_contexts.py +9 -8
contentious_contexts.py CHANGED
@@ -97,20 +97,21 @@ class ContentiousContexts(datasets.GeneratorBasedBuilder):
97
  return [
98
  datasets.SplitGenerator(
99
  name=datasets.Split.TRAIN,
100
- gen_kwargs={"filepaths": [ann_file, text_file], "split": "train",},
101
  ),
102
  ]
103
 
104
- def _generate_examples(self, filepaths, split):
105
- annotations = pd.read_csv(filepaths[0], dtype="object")
106
- texts = pd.read_csv(filepaths[1], dtype="object")
107
  annotations.fillna("", inplace=True)
108
  texts.fillna("", inplace=True)
109
  for _, row in texts.iterrows():
110
- data_point = {}
111
- data_point["extract_id"] = row["extract_id"]
112
- data_point["target"] = row["target_compound_bolded"]
113
- data_point["text"] = row["text"]
 
114
  annotator_responses = annotations[
115
  annotations["extract_id"] == row["extract_id"]
116
  ]
 
97
  return [
98
  datasets.SplitGenerator(
99
  name=datasets.Split.TRAIN,
100
+ gen_kwargs={"ann_file": ann_file, "text_file": text_file},
101
  ),
102
  ]
103
 
104
+ def _generate_examples(self, ann_file, text_file):
105
+ annotations = pd.read_csv(open(ann_file), dtype="object")
106
+ texts = pd.read_csv(open(text_file), dtype="object")
107
  annotations.fillna("", inplace=True)
108
  texts.fillna("", inplace=True)
109
  for _, row in texts.iterrows():
110
+ data_point = {
111
+ "extract_id": row["extract_id"],
112
+ "target": row["target_compound_bolded"],
113
+ "text": row["text"],
114
+ }
115
  annotator_responses = annotations[
116
  annotations["extract_id"] == row["extract_id"]
117
  ]