Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- README.md +2 -1
- inquisitive_qg.py +11 -8
README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
---
|
|
|
2 |
annotations_creators:
|
3 |
- crowdsourced
|
4 |
language_creators:
|
@@ -20,7 +21,7 @@ task_ids:
|
|
20 |
paperswithcode_id: inquisitive
|
21 |
---
|
22 |
|
23 |
-
# Dataset Card
|
24 |
|
25 |
## Table of Contents
|
26 |
- [Dataset Description](#dataset-description)
|
|
|
1 |
---
|
2 |
+
pretty_name: InquisitiveQg
|
3 |
annotations_creators:
|
4 |
- crowdsourced
|
5 |
language_creators:
|
|
|
21 |
paperswithcode_id: inquisitive
|
22 |
---
|
23 |
|
24 |
+
# Dataset Card for InquisitiveQg
|
25 |
|
26 |
## Table of Contents
|
27 |
- [Dataset Description](#dataset-description)
|
inquisitive_qg.py
CHANGED
@@ -18,7 +18,6 @@
|
|
18 |
|
19 |
|
20 |
import itertools
|
21 |
-
import os
|
22 |
|
23 |
import datasets
|
24 |
|
@@ -95,8 +94,8 @@ class InquisitiveQg(datasets.GeneratorBasedBuilder):
|
|
95 |
|
96 |
def _split_generators(self, dl_manager):
|
97 |
questions_file = dl_manager.download(_QUESTIONS_URL)
|
98 |
-
|
99 |
-
articles_dir =
|
100 |
|
101 |
return [
|
102 |
datasets.SplitGenerator(
|
@@ -105,6 +104,7 @@ class InquisitiveQg(datasets.GeneratorBasedBuilder):
|
|
105 |
"articles_dir": articles_dir,
|
106 |
"questions_file": questions_file,
|
107 |
"article_ids": TRAIN_ARTICLE_IDS,
|
|
|
108 |
},
|
109 |
),
|
110 |
datasets.SplitGenerator(
|
@@ -113,6 +113,7 @@ class InquisitiveQg(datasets.GeneratorBasedBuilder):
|
|
113 |
"articles_dir": articles_dir,
|
114 |
"questions_file": questions_file,
|
115 |
"article_ids": DEV_ARTICLE_IDS,
|
|
|
116 |
},
|
117 |
),
|
118 |
datasets.SplitGenerator(
|
@@ -121,11 +122,15 @@ class InquisitiveQg(datasets.GeneratorBasedBuilder):
|
|
121 |
"articles_dir": articles_dir,
|
122 |
"questions_file": questions_file,
|
123 |
"article_ids": TEST_ARTICLE_IDS,
|
|
|
124 |
},
|
125 |
),
|
126 |
]
|
127 |
|
128 |
-
def _generate_examples(self, articles_dir, questions_file, article_ids):
|
|
|
|
|
|
|
129 |
with open(questions_file, encoding="utf-8") as f:
|
130 |
questions_counter = 0
|
131 |
rows = f.readlines()
|
@@ -139,11 +144,9 @@ class InquisitiveQg(datasets.GeneratorBasedBuilder):
|
|
139 |
if article_id not in article_ids:
|
140 |
continue
|
141 |
|
142 |
-
# read the article file
|
143 |
fname = str(article_id).rjust(4, "0") + ".txt"
|
144 |
-
article_path =
|
145 |
-
|
146 |
-
article = f.read()
|
147 |
|
148 |
id_ = str(questions_counter)
|
149 |
example = {
|
|
|
18 |
|
19 |
|
20 |
import itertools
|
|
|
21 |
|
22 |
import datasets
|
23 |
|
|
|
94 |
|
95 |
def _split_generators(self, dl_manager):
|
96 |
questions_file = dl_manager.download(_QUESTIONS_URL)
|
97 |
+
archive = dl_manager.download(_ARTICLES_URL)
|
98 |
+
articles_dir = "article"
|
99 |
|
100 |
return [
|
101 |
datasets.SplitGenerator(
|
|
|
104 |
"articles_dir": articles_dir,
|
105 |
"questions_file": questions_file,
|
106 |
"article_ids": TRAIN_ARTICLE_IDS,
|
107 |
+
"files": dl_manager.iter_archive(archive),
|
108 |
},
|
109 |
),
|
110 |
datasets.SplitGenerator(
|
|
|
113 |
"articles_dir": articles_dir,
|
114 |
"questions_file": questions_file,
|
115 |
"article_ids": DEV_ARTICLE_IDS,
|
116 |
+
"files": dl_manager.iter_archive(archive),
|
117 |
},
|
118 |
),
|
119 |
datasets.SplitGenerator(
|
|
|
122 |
"articles_dir": articles_dir,
|
123 |
"questions_file": questions_file,
|
124 |
"article_ids": TEST_ARTICLE_IDS,
|
125 |
+
"files": dl_manager.iter_archive(archive),
|
126 |
},
|
127 |
),
|
128 |
]
|
129 |
|
130 |
+
def _generate_examples(self, articles_dir, questions_file, article_ids, files):
|
131 |
+
articles = {}
|
132 |
+
for path, f in files:
|
133 |
+
articles[path] = f.read().decode("utf-8")
|
134 |
with open(questions_file, encoding="utf-8") as f:
|
135 |
questions_counter = 0
|
136 |
rows = f.readlines()
|
|
|
144 |
if article_id not in article_ids:
|
145 |
continue
|
146 |
|
|
|
147 |
fname = str(article_id).rjust(4, "0") + ".txt"
|
148 |
+
article_path = articles_dir + "/" + fname
|
149 |
+
article = articles[article_path]
|
|
|
150 |
|
151 |
id_ = str(questions_counter)
|
152 |
example = {
|