Lurunchik commited on
Commit
afb5c76
1 Parent(s): 655e03b

add splitting

Browse files
Files changed (1) hide show
  1. WikiHowNFQA.py +36 -10
WikiHowNFQA.py CHANGED
@@ -30,20 +30,46 @@ class WikiHowNFQADataset(GeneratorBasedBuilder):
30
  )
31
 
32
  def _split_generators(self, dl_manager):
 
33
  downloaded_file = dl_manager.download_and_extract('https://huggingface.co/datasets/Lurunchik/WikiHowNFQA/resolve/main/WikiHowNFQA.jsonl')
 
34
  return [
35
- SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": downloaded_file}),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  ]
37
 
38
- def _generate_examples(self, filepath):
39
  with open(filepath, encoding="utf-8") as f:
40
  for id_, line in enumerate(f):
41
  data = json.loads(line)
42
- yield id_, {
43
- 'article_id': data['article_id'],
44
- 'question': data['question'],
45
- 'answer': data['answer'],
46
- 'related_document_urls_wayback_snapshots': data['related_document_urls_wayback_snapshots'],
47
- 'split': data['split'],
48
- 'cluster': data['cluster'],
49
- }
 
 
 
 
 
30
  )
31
 
32
  def _split_generators(self, dl_manager):
33
+ """Returns SplitGenerators."""
34
  downloaded_file = dl_manager.download_and_extract('https://huggingface.co/datasets/Lurunchik/WikiHowNFQA/resolve/main/WikiHowNFQA.jsonl')
35
+
36
  return [
37
+ SplitGenerator(
38
+ name=Split.TRAIN,
39
+ gen_kwargs={
40
+ "filepath": downloaded_file,
41
+ "split": "train",
42
+ },
43
+ ),
44
+ SplitGenerator(
45
+ name=Split.VALIDATION,
46
+ gen_kwargs={
47
+ "filepath": downloaded_file,
48
+ "split": "valid",
49
+ },
50
+ ),
51
+ SplitGenerator(
52
+ name=Split.TEST,
53
+ gen_kwargs={
54
+ "filepath": downloaded_file,
55
+ "split": "test",
56
+ },
57
+ ),
58
  ]
59
 
60
+ def _generate_examples(self, filepath, split):
61
  with open(filepath, encoding="utf-8") as f:
62
  for id_, line in enumerate(f):
63
  data = json.loads(line)
64
+ if data['split'] == split:
65
+ yield id_, {
66
+ 'article_id': data['article_id'],
67
+ 'question': data['question'],
68
+ 'answer': data['answer'],
69
+ 'related_document_urls_wayback_snapshots': data['related_document_urls_wayback_snapshots'],
70
+ 'split': data['split'],
71
+ 'cluster': data['cluster'],
72
+ }
73
+
74
+
75
+ WikiHowNFQADataset().download_and_prepare()