Update wikipedia-nq.py
Browse files- wikipedia-nq.py +12 -11
wikipedia-nq.py
CHANGED
|
@@ -96,15 +96,16 @@ class WikipediaNq(datasets.GeneratorBasedBuilder):
|
|
| 96 |
]
|
| 97 |
return splits
|
| 98 |
|
| 99 |
-
def _generate_examples(self,
|
| 100 |
"""Yields examples."""
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
data
|
| 106 |
-
|
| 107 |
-
data
|
| 108 |
-
|
| 109 |
-
data
|
| 110 |
-
|
|
|
|
|
|
| 96 |
]
|
| 97 |
return splits
|
| 98 |
|
| 99 |
+
def _generate_examples(self, files):
|
| 100 |
"""Yields examples."""
|
| 101 |
+
for filepath in files:
|
| 102 |
+
with open(filepath, encoding="utf-8") as f:
|
| 103 |
+
for line in f:
|
| 104 |
+
data = json.loads(line)
|
| 105 |
+
if data.get('negative_passages') is None:
|
| 106 |
+
data['negative_passages'] = []
|
| 107 |
+
if data.get('positive_passages') is None:
|
| 108 |
+
data['positive_passages'] = []
|
| 109 |
+
if data.get('answers') is None:
|
| 110 |
+
data['answers'] = []
|
| 111 |
+
yield data['query_id'], data
|