Konrad Wojtasik
commited on
Commit
•
e91b0ad
1
Parent(s):
d5ce1cf
Add dataset
Browse files- corpus.jsonl.gz +3 -0
- queries.jsonl.gz +3 -0
- quora-pl.py +58 -0
corpus.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:019aaece18e25fd2de4fb32ea3f8ed1401f1cbfb2a4810bbd987326a57940e5c
|
3 |
+
size 17771406
|
queries.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a7d6c7f4545067475af7f1cc43d60b8b549e9a89a82a876b5c87d3a1dcf01c4f
|
3 |
+
size 452919
|
quora-pl.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import csv
|
3 |
+
import os
|
4 |
+
import datasets
|
5 |
+
|
6 |
+
logger = datasets.logging.get_logger(__name__)
|
7 |
+
|
8 |
+
_DESCRIPTION = "QUORA-PL 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-PL BenchmarkDataset."""
|
16 |
+
|
17 |
+
BUILDER_CONFIGS = [
|
18 |
+
datasets.BuilderConfig(
|
19 |
+
name=name,
|
20 |
+
description=f"This is the {name} in the Scifact-PL 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 |
+
|
36 |
+
def _split_generators(self, dl_manager):
|
37 |
+
"""Returns SplitGenerators."""
|
38 |
+
|
39 |
+
my_urls = _URLs[self.config.name]
|
40 |
+
data_dir = dl_manager.download_and_extract(my_urls)
|
41 |
+
|
42 |
+
return [
|
43 |
+
datasets.SplitGenerator(
|
44 |
+
name=self.config.name,
|
45 |
+
# These kwargs will be passed to _generate_examples
|
46 |
+
gen_kwargs={"filepath": data_dir},
|
47 |
+
),
|
48 |
+
]
|
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
|