Datasets:
Languages:
Portuguese
License:
leonardo-avila
commited on
Commit
•
4aec797
1
Parent(s):
7bc0c58
Update fiqa_pt.py
Browse files- fiqa_pt.py +12 -31
fiqa_pt.py
CHANGED
@@ -10,7 +10,6 @@ _SPLITS = ["corpus", "queries"]
|
|
10 |
|
11 |
URL = ""
|
12 |
_URLs = {subset: URL + f"{subset}.jsonl.gz" for subset in _SPLITS}
|
13 |
-
_URLs.update({"qrel": URL + "qrels.tsv"})
|
14 |
|
15 |
class BEIR(datasets.GeneratorBasedBuilder):
|
16 |
"""BEIR BenchmarkDataset."""
|
@@ -19,26 +18,18 @@ class BEIR(datasets.GeneratorBasedBuilder):
|
|
19 |
datasets.BuilderConfig(
|
20 |
name=name,
|
21 |
description=f"This is the {name} in the FiQA dataset.",
|
22 |
-
) for name in _SPLITS
|
23 |
]
|
24 |
|
25 |
def _info(self):
|
26 |
|
27 |
-
|
|
|
28 |
features=datasets.Features({
|
29 |
"_id": datasets.Value("string"),
|
30 |
"title": datasets.Value("string"),
|
31 |
-
|
32 |
-
|
33 |
-
else:
|
34 |
-
features = datasets.Features({
|
35 |
-
"query_id": datasets.Value("string"),
|
36 |
-
"doc_id": datasets.Value("string"),
|
37 |
-
"rel": datasets.Value("string")
|
38 |
-
})
|
39 |
-
return datasets.DatasetInfo(
|
40 |
-
description=_DESCRIPTION,
|
41 |
-
features=features,
|
42 |
supervised_keys=None,
|
43 |
)
|
44 |
|
@@ -58,20 +49,10 @@ class BEIR(datasets.GeneratorBasedBuilder):
|
|
58 |
|
59 |
def _generate_examples(self, filepath):
|
60 |
"""Yields examples."""
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
yield i, text
|
69 |
-
else:
|
70 |
-
with open(filepath, encoding="utf-8") as f:
|
71 |
-
for line in f:
|
72 |
-
if "query-id" not in line:
|
73 |
-
fields = line.strip().split("\t")
|
74 |
-
query_id = fields[0]
|
75 |
-
doc_id = fields[1]
|
76 |
-
rel = int(fields[2])
|
77 |
-
yield query_id, doc_id, rel
|
|
|
10 |
|
11 |
URL = ""
|
12 |
_URLs = {subset: URL + f"{subset}.jsonl.gz" for subset in _SPLITS}
|
|
|
13 |
|
14 |
class BEIR(datasets.GeneratorBasedBuilder):
|
15 |
"""BEIR BenchmarkDataset."""
|
|
|
18 |
datasets.BuilderConfig(
|
19 |
name=name,
|
20 |
description=f"This is the {name} in the FiQA dataset.",
|
21 |
+
) for name in _SPLITS
|
22 |
]
|
23 |
|
24 |
def _info(self):
|
25 |
|
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,
|
34 |
)
|
35 |
|
|
|
49 |
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|