thinkall commited on
Commit
2942d43
·
1 Parent(s): 6cb7217

Update 2wikimultihopqa.py

Browse files
Files changed (1) hide show
  1. 2wikimultihopqa.py +8 -1
2wikimultihopqa.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import json
 
3
 
4
  data = json.loads(open("dev.json").read())
5
 
@@ -21,11 +22,17 @@ here = os.path.dirname(os.path.abspath("."))
21
 
22
 
23
  def prepare_json_dataset():
 
24
  with open(os.path.join(here, "corpus.txt"), "w") as fout:
25
  with open(os.path.join(here, "corpus.jsonl"), "r") as fin:
26
  for line in fin:
27
  line = json.loads(line)
28
- fout.write(line["text"] + "\n")
 
 
 
 
 
29
 
30
 
31
  prepare_json_dataset()
 
1
  import os
2
  import json
3
+ import hashlib
4
 
5
  data = json.loads(open("dev.json").read())
6
 
 
22
 
23
 
24
  def prepare_json_dataset():
25
+ hash_ids = set()
26
  with open(os.path.join(here, "corpus.txt"), "w") as fout:
27
  with open(os.path.join(here, "corpus.jsonl"), "r") as fin:
28
  for line in fin:
29
  line = json.loads(line)
30
+ hash_id = hashlib.md5(line["text"].encode("utf-8")).hexdigest()
31
+ if hash_id in hash_ids:
32
+ continue
33
+ else:
34
+ fout.write(line["text"] + "\n")
35
+ hash_ids.add(hash_id)
36
 
37
 
38
  prepare_json_dataset()