Update spanish_passage_retrieval.py
Browse files- spanish_passage_retrieval.py +11 -25
spanish_passage_retrieval.py
CHANGED
@@ -2,8 +2,6 @@
|
|
2 |
|
3 |
|
4 |
import json
|
5 |
-
import tempfile
|
6 |
-
import patoolib
|
7 |
import csv
|
8 |
|
9 |
import os
|
@@ -17,7 +15,7 @@ _LANGUAGES = {'es': 'ES'}
|
|
17 |
_VERSION = '1.0.0'
|
18 |
|
19 |
|
20 |
-
URL = '
|
21 |
|
22 |
|
23 |
class PRESConfig(datasets.BuilderConfig):
|
@@ -30,7 +28,7 @@ class PRESConfig(datasets.BuilderConfig):
|
|
30 |
|
31 |
|
32 |
class PRES(datasets.GeneratorBasedBuilder):
|
33 |
-
"""The
|
34 |
|
35 |
BUILDER_CONFIGS = [
|
36 |
datasets.BuilderConfig(
|
@@ -59,37 +57,25 @@ class PRES(datasets.GeneratorBasedBuilder):
|
|
59 |
homepage=_HOMEPAGE_URL,
|
60 |
)
|
61 |
|
62 |
-
def _split_generators(self, dl_manager
|
63 |
-
downloaded_archive = dl_manager.download(URL)
|
64 |
return [
|
65 |
-
datasets.SplitGenerator(
|
66 |
-
name=datasets.Split.TEST,
|
67 |
-
gen_kwargs={
|
68 |
-
'archive': downloaded_archive,
|
69 |
-
'split': 'test',
|
70 |
-
},
|
71 |
-
),
|
72 |
]
|
73 |
|
74 |
def _generate_examples(
|
75 |
self,
|
76 |
-
archive: str,
|
77 |
split: str = None,
|
78 |
):
|
79 |
|
80 |
if not self._data:
|
81 |
-
with
|
82 |
-
|
83 |
-
extracted_path = os.path.join(tmpdir, 'PRES Dataset')
|
84 |
-
|
85 |
-
with open(os.path.join(extracted_path, 'docs.json')) as f:
|
86 |
-
docs = json.load(f)
|
87 |
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
|
94 |
corpus_sentences = []
|
95 |
corpus_documents = []
|
@@ -150,4 +136,4 @@ class PRES(datasets.GeneratorBasedBuilder):
|
|
150 |
yield qid, {
|
151 |
"_id": qid,
|
152 |
"text": ' '.join(dids),
|
153 |
-
}
|
|
|
2 |
|
3 |
|
4 |
import json
|
|
|
|
|
5 |
import csv
|
6 |
|
7 |
import os
|
|
|
15 |
_VERSION = '1.0.0'
|
16 |
|
17 |
|
18 |
+
URL = 'https://huggingface.co/datasets/jinaai/spanish_passage_retrieval/resolve/main/'
|
19 |
|
20 |
|
21 |
class PRESConfig(datasets.BuilderConfig):
|
|
|
28 |
|
29 |
|
30 |
class PRES(datasets.GeneratorBasedBuilder):
|
31 |
+
"""The Spanish Passage Retrieval dataset (PRES)"""
|
32 |
|
33 |
BUILDER_CONFIGS = [
|
34 |
datasets.BuilderConfig(
|
|
|
57 |
homepage=_HOMEPAGE_URL,
|
58 |
)
|
59 |
|
60 |
+
def _split_generators(self, dl_manager):
|
|
|
61 |
return [
|
62 |
+
datasets.SplitGenerator(name=datasets.Split.TEST),
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
]
|
64 |
|
65 |
def _generate_examples(
|
66 |
self,
|
|
|
67 |
split: str = None,
|
68 |
):
|
69 |
|
70 |
if not self._data:
|
71 |
+
with open(os.path.join(URL, 'docs.json')) as f:
|
72 |
+
docs = json.load(f)
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
with open(os.path.join(URL, 'topics.json')) as f:
|
75 |
+
topics = json.load(f)
|
76 |
|
77 |
+
with open(os.path.join(URL, 'relevance_passages.json')) as f:
|
78 |
+
rel_passages = json.load(f)
|
79 |
|
80 |
corpus_sentences = []
|
81 |
corpus_documents = []
|
|
|
136 |
yield qid, {
|
137 |
"_id": qid,
|
138 |
"text": ' '.join(dids),
|
139 |
+
}
|