MrLight commited on
Commit
37a7d5b
1 Parent(s): b858392

Update wikipedia-nq.py

Browse files
Files changed (1) hide show
  1. 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, filepath):
100
  """Yields examples."""
101
- with open(filepath, encoding="utf-8") as f:
102
- for line in f:
103
- data = json.loads(line)
104
- if data.get('negative_passages') is None:
105
- data['negative_passages'] = []
106
- if data.get('positive_passages') is None:
107
- data['positive_passages'] = []
108
- if data.get('answers') is None:
109
- data['answers'] = []
110
- yield data['query_id'], data
 
 
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