leonardo-avila commited on
Commit
9b7017e
1 Parent(s): 224ca7c

Update fiqa_pt.py

Browse files
Files changed (1) hide show
  1. fiqa_pt.py +8 -10
fiqa_pt.py CHANGED
@@ -6,10 +6,10 @@ import datasets
6
  logger = datasets.logging.get_logger(__name__)
7
 
8
  _DESCRIPTION = "FIQA Dataset"
9
- _SPLITS = ["corpus", "queries"]
10
 
11
  URL = ""
12
- _URLs = {subset: URL + f"{subset}.jsonl.gz" for subset in _SPLITS}
13
 
14
  class BEIR(datasets.GeneratorBasedBuilder):
15
  """BEIR BenchmarkDataset."""
@@ -26,8 +26,7 @@ class BEIR(datasets.GeneratorBasedBuilder):
26
  return datasets.DatasetInfo(
27
  description=_DESCRIPTION,
28
  features=datasets.Features({
29
- "_id": datasets.Value("string"),
30
- "title": datasets.Value("string"),
31
  "text": datasets.Value("string"),
32
  }),
33
  supervised_keys=None,
@@ -50,9 +49,8 @@ class BEIR(datasets.GeneratorBasedBuilder):
50
  def _generate_examples(self, filepath):
51
  """Yields examples."""
52
  with open(filepath, encoding="utf-8") as f:
53
- texts = f.readlines()
54
- for i, text in enumerate(texts):
55
- text = json.loads(text)
56
- if 'metadata' in text: del text['metadata']
57
- if "title" not in text: text["title"] = ""
58
- yield i, text
 
6
  logger = datasets.logging.get_logger(__name__)
7
 
8
  _DESCRIPTION = "FIQA Dataset"
9
+ _SPLITS = ["corpus", "topics"]
10
 
11
  URL = ""
12
+ _URLs = {subset: URL + f"{subset}.tsv" for subset in _SPLITS}
13
 
14
  class BEIR(datasets.GeneratorBasedBuilder):
15
  """BEIR BenchmarkDataset."""
 
26
  return datasets.DatasetInfo(
27
  description=_DESCRIPTION,
28
  features=datasets.Features({
29
+ "id": datasets.Value("string"),
 
30
  "text": datasets.Value("string"),
31
  }),
32
  supervised_keys=None,
 
49
  def _generate_examples(self, filepath):
50
  """Yields examples."""
51
  with open(filepath, encoding="utf-8") as f:
52
+ for line in f:
53
+ fields = line.strip().split("\t")
54
+ idx = fields[0]
55
+ text = fields[1]
56
+ yield idx, text