Datasets:
Commit
•
85f1adb
1
Parent(s):
2642eea
small refactor (#1)
Browse files- small refactor (51e4195ad8acbc0259daa1f95dc0a0cdd12d66f3)
Co-authored-by: Daniel van Strien <davanstrien@users.noreply.huggingface.co>
- 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 |
]
|