Upload 3 files
Browse files- corpus.jsonl.gz +3 -0
- mathematica.py +57 -0
- queries.jsonl.gz +3 -0
corpus.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6dfd60bb5a007fd03ae688d0d0a04d18c12b8bd3c16b1279919c36eb8bb9d190
|
3 |
+
size 7959051
|
mathematica.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import csv
|
3 |
+
import os
|
4 |
+
import datasets
|
5 |
+
|
6 |
+
logger = datasets.logging.get_logger(__name__)
|
7 |
+
|
8 |
+
_DESCRIPTION = "cqadupstack mathematica Dataset"
|
9 |
+
_SPLITS = ["corpus", "queries"]
|
10 |
+
|
11 |
+
URL = ""
|
12 |
+
_URLs = {subset: URL + f"{subset}.jsonl.gz" for subset in _SPLITS}
|
13 |
+
|
14 |
+
class Mathematica(datasets.GeneratorBasedBuilder):
|
15 |
+
|
16 |
+
BUILDER_CONFIGS = [
|
17 |
+
datasets.BuilderConfig(
|
18 |
+
name=name,
|
19 |
+
description=f"This is the {name} in the BEIR-PL dataset.",
|
20 |
+
) for name in _SPLITS
|
21 |
+
]
|
22 |
+
|
23 |
+
def _info(self):
|
24 |
+
|
25 |
+
return datasets.DatasetInfo(
|
26 |
+
description=_DESCRIPTION,
|
27 |
+
features=datasets.Features({
|
28 |
+
"_id": datasets.Value("string"),
|
29 |
+
"title": datasets.Value("string"),
|
30 |
+
"text": datasets.Value("string"),
|
31 |
+
}),
|
32 |
+
supervised_keys=None,
|
33 |
+
)
|
34 |
+
|
35 |
+
def _split_generators(self, dl_manager):
|
36 |
+
"""Returns SplitGenerators."""
|
37 |
+
|
38 |
+
my_urls = _URLs[self.config.name]
|
39 |
+
data_dir = dl_manager.download_and_extract(my_urls)
|
40 |
+
|
41 |
+
return [
|
42 |
+
datasets.SplitGenerator(
|
43 |
+
name=self.config.name,
|
44 |
+
# These kwargs will be passed to _generate_examples
|
45 |
+
gen_kwargs={"filepath": data_dir},
|
46 |
+
),
|
47 |
+
]
|
48 |
+
|
49 |
+
def _generate_examples(self, filepath):
|
50 |
+
"""Yields examples."""
|
51 |
+
with open(filepath, encoding="utf-8") as f:
|
52 |
+
texts = f.readlines()
|
53 |
+
for i, text in enumerate(texts):
|
54 |
+
text = json.loads(text)
|
55 |
+
if 'metadata' in text: del text['metadata']
|
56 |
+
if "title" not in text: text["title"] = ""
|
57 |
+
yield i, text
|
queries.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:daa3fb6bec155769a958bfe3f92cc6e29203b914ec1756bd67dc574ae36e7462
|
3 |
+
size 215981309
|