Datasets:
small refactor
#1
by
davanstrien
HF Staff
- opened
- 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={"
|
| 101 |
),
|
| 102 |
]
|
| 103 |
|
| 104 |
-
def _generate_examples(self,
|
| 105 |
-
annotations = pd.read_csv(
|
| 106 |
-
texts = pd.read_csv(
|
| 107 |
annotations.fillna("", inplace=True)
|
| 108 |
texts.fillna("", inplace=True)
|
| 109 |
for _, row in texts.iterrows():
|
| 110 |
-
data_point = {
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 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 |
]
|