crystina-z commited on
Commit
4db9341
1 Parent(s): be3c9e0

Update xor-tydi.py

Browse files
Files changed (1) hide show
  1. xor-tydi.py +4 -3
xor-tydi.py CHANGED
@@ -22,6 +22,7 @@ import random
22
  random.seed(42)
23
 
24
  import datasets
 
25
 
26
  _CITATION = """
27
  @inproceedings{xorqa,
@@ -121,13 +122,13 @@ class XORTyDi(datasets.GeneratorBasedBuilder):
121
  hard_negative_ctxs = data["hard_negative_ctxs"]
122
  # each ctx: {'title':... , 'text': ....}
123
 
124
- _id = f"{_id}-{random.randint()}"
125
  return _id, {
126
  "query_id": _id,
127
  "query": data["question"],
128
  "answers": data.get("answers", []),
129
- "positive_passages": [{**doc, 'docid': f'pos-{i}-{random.randint()}'} for i, doc in enumerate(positive_ctxs)],
130
- "negative_passages": [{**doc, 'docid': f'neg-{i}-{random.randint()}'} for i, doc in enumerate(hard_negative_ctxs)],
131
  }
132
 
133
  def process_dev_test_entry(data):
 
22
  random.seed(42)
23
 
24
  import datasets
25
+ RANGE = (0, 1000)
26
 
27
  _CITATION = """
28
  @inproceedings{xorqa,
 
122
  hard_negative_ctxs = data["hard_negative_ctxs"]
123
  # each ctx: {'title':... , 'text': ....}
124
 
125
+ _id = f"{_id}-{random.randint(*RANGE)}"
126
  return _id, {
127
  "query_id": _id,
128
  "query": data["question"],
129
  "answers": data.get("answers", []),
130
+ "positive_passages": [{**doc, 'docid': f'pos-{i}-{random.randint(*RANGE)}'} for i, doc in enumerate(positive_ctxs)],
131
+ "negative_passages": [{**doc, 'docid': f'neg-{i}-{random.randint(*RANGE)}'} for i, doc in enumerate(hard_negative_ctxs)],
132
  }
133
 
134
  def process_dev_test_entry(data):