Giguru Scheuer
commited on
Commit
·
445f168
1
Parent(s):
a50bb4c
Added download sizes and implemented generate_examples for 'test_collection'
Browse files- trec-cast-2019-multi-turn.py +25 -10
trec-cast-2019-multi-turn.py
CHANGED
|
@@ -49,17 +49,13 @@ _URLs = {
|
|
| 49 |
'topics': _URL+"cast2019_test_annotated.tsv",
|
| 50 |
'qrels': _URL+"2019qrels.txt",
|
| 51 |
'test_collection': {
|
| 52 |
-
'msmarco': 'https://msmarco.blob.core.windows.net/msmarcoranking/collection.tar.gz',
|
| 53 |
'car': "http://trec-car.cs.unh.edu/datareleases/v2.0/paragraphCorpus.v2.0.tar.xz",
|
|
|
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
|
| 58 |
class TrecCast2019MultiTurn(datasets.GeneratorBasedBuilder):
|
| 59 |
-
"""
|
| 60 |
-
|
| 61 |
-
"""
|
| 62 |
-
|
| 63 |
VERSION = datasets.Version("1.0.0")
|
| 64 |
|
| 65 |
# This is an example of a dataset with multiple configurations.
|
|
@@ -90,24 +86,29 @@ class TrecCast2019MultiTurn(datasets.GeneratorBasedBuilder):
|
|
| 90 |
|
| 91 |
def _info(self):
|
| 92 |
# This is the name of the configuration selected in BUILDER_CONFIGS above
|
|
|
|
| 93 |
if self.config.name == "topics":
|
| 94 |
features = datasets.Features({
|
| 95 |
"qid": datasets.Value("string"),
|
| 96 |
"history": datasets.features.Sequence(feature=datasets.Value('string')),
|
| 97 |
"query": datasets.Value("string"),
|
| 98 |
})
|
|
|
|
| 99 |
elif self.config.name == "qrels":
|
| 100 |
features = datasets.Features({
|
| 101 |
"qid": datasets.Value("string"),
|
| 102 |
"qrels": datasets.features.Sequence(feature=datasets.Features({
|
| 103 |
'docno': datasets.Value("string"),
|
| 104 |
-
'
|
| 105 |
})),
|
| 106 |
})
|
|
|
|
| 107 |
elif self.config.name == 'test_collection':
|
| 108 |
features = datasets.Features({
|
| 109 |
-
"
|
|
|
|
| 110 |
})
|
|
|
|
| 111 |
return datasets.DatasetInfo(
|
| 112 |
# This is the description that will appear on the datasets page.
|
| 113 |
description=_DESCRIPTION,
|
|
@@ -123,6 +124,7 @@ class TrecCast2019MultiTurn(datasets.GeneratorBasedBuilder):
|
|
| 123 |
license=_LICENSE,
|
| 124 |
# Citation for the dataset
|
| 125 |
citation=_CITATION,
|
|
|
|
| 126 |
)
|
| 127 |
|
| 128 |
def _split_generators(self, dl_manager):
|
|
@@ -158,8 +160,8 @@ class TrecCast2019MultiTurn(datasets.GeneratorBasedBuilder):
|
|
| 158 |
for row in qrels_file:
|
| 159 |
qid = row[0]
|
| 160 |
docno = row[2]
|
| 161 |
-
|
| 162 |
-
qrels[qid].append({'docno': docno, '
|
| 163 |
|
| 164 |
for qid in qrels.keys():
|
| 165 |
yield qid, {'qid': qid, 'qrels': qrels[qid]}
|
|
@@ -178,6 +180,19 @@ class TrecCast2019MultiTurn(datasets.GeneratorBasedBuilder):
|
|
| 178 |
query = queries[idx]
|
| 179 |
qid = f"{conversation_id}_{str(idx+1)}"
|
| 180 |
yield qid, ({'query': query, 'history': queries[:idx], 'qid': qid})
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
else:
|
| 183 |
raise NotImplementedError(f"'{split}' is not yet implemented")
|
|
|
|
| 49 |
'topics': _URL+"cast2019_test_annotated.tsv",
|
| 50 |
'qrels': _URL+"2019qrels.txt",
|
| 51 |
'test_collection': {
|
|
|
|
| 52 |
'car': "http://trec-car.cs.unh.edu/datareleases/v2.0/paragraphCorpus.v2.0.tar.xz",
|
| 53 |
+
'msmarco': 'https://msmarco.blob.core.windows.net/msmarcoranking/collection.tar.gz',
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
|
| 58 |
class TrecCast2019MultiTurn(datasets.GeneratorBasedBuilder):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
VERSION = datasets.Version("1.0.0")
|
| 60 |
|
| 61 |
# This is an example of a dataset with multiple configurations.
|
|
|
|
| 86 |
|
| 87 |
def _info(self):
|
| 88 |
# This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 89 |
+
download_size = None
|
| 90 |
if self.config.name == "topics":
|
| 91 |
features = datasets.Features({
|
| 92 |
"qid": datasets.Value("string"),
|
| 93 |
"history": datasets.features.Sequence(feature=datasets.Value('string')),
|
| 94 |
"query": datasets.Value("string"),
|
| 95 |
})
|
| 96 |
+
download_size = 1138032
|
| 97 |
elif self.config.name == "qrels":
|
| 98 |
features = datasets.Features({
|
| 99 |
"qid": datasets.Value("string"),
|
| 100 |
"qrels": datasets.features.Sequence(feature=datasets.Features({
|
| 101 |
'docno': datasets.Value("string"),
|
| 102 |
+
'relevance': datasets.Value("string"),
|
| 103 |
})),
|
| 104 |
})
|
| 105 |
+
download_size = 8010
|
| 106 |
elif self.config.name == 'test_collection':
|
| 107 |
features = datasets.Features({
|
| 108 |
+
"docno": datasets.Value("string"),
|
| 109 |
+
"text": datasets.Value("string"),
|
| 110 |
})
|
| 111 |
+
download_size = 5085726092 + 1035009698
|
| 112 |
return datasets.DatasetInfo(
|
| 113 |
# This is the description that will appear on the datasets page.
|
| 114 |
description=_DESCRIPTION,
|
|
|
|
| 124 |
license=_LICENSE,
|
| 125 |
# Citation for the dataset
|
| 126 |
citation=_CITATION,
|
| 127 |
+
download_size=download_size
|
| 128 |
)
|
| 129 |
|
| 130 |
def _split_generators(self, dl_manager):
|
|
|
|
| 160 |
for row in qrels_file:
|
| 161 |
qid = row[0]
|
| 162 |
docno = row[2]
|
| 163 |
+
relevance = row[3]
|
| 164 |
+
qrels[qid].append({'docno': docno, 'relevance': relevance})
|
| 165 |
|
| 166 |
for qid in qrels.keys():
|
| 167 |
yield qid, {'qid': qid, 'qrels': qrels[qid]}
|
|
|
|
| 180 |
query = queries[idx]
|
| 181 |
qid = f"{conversation_id}_{str(idx+1)}"
|
| 182 |
yield qid, ({'query': query, 'history': queries[:idx], 'qid': qid})
|
| 183 |
+
elif split == 'test_collection':
|
| 184 |
+
with open(file['msmarco']+"/collection.tsv") as f:
|
| 185 |
+
msmarco = csv.reader(f, delimiter="\t")
|
| 186 |
+
for line in msmarco:
|
| 187 |
+
docid, text = line
|
| 188 |
+
docid = f"MARCO_{docid}"
|
| 189 |
+
yield docid, ({"docno": docid, "text": text})
|
| 190 |
+
|
| 191 |
+
with open(file['car']+"/collection.tsv", 'rb') as f:
|
| 192 |
+
car = csv.reader(f, delimiter="\t")
|
| 193 |
+
for line in car:
|
| 194 |
+
docid, text = line.split(" ")
|
| 195 |
+
docid = f"CAR_{docid}"
|
| 196 |
+
yield docid, ({"docno": docid, "text": text})
|
| 197 |
else:
|
| 198 |
raise NotImplementedError(f"'{split}' is not yet implemented")
|