Commit
·
7f5ff3a
1
Parent(s):
e024685
add data and script
Browse files- .gitattributes +1 -0
- en_wiki.tsv +3 -0
- xor-tydi.py +118 -0
.gitattributes
CHANGED
@@ -52,3 +52,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
55 |
+
en_wiki.tsv filter=lfs diff=lfs merge=lfs -text
|
en_wiki.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fca6f2a9be902b2947505b50b622b4c28d509390bbd48713e69a567c197e2044
|
3 |
+
size 11645625207
|
xor-tydi.py
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
# TODO: Address all TODOs and remove all explanatory comments
|
15 |
+
"""TODO: Add a description here."""
|
16 |
+
|
17 |
+
|
18 |
+
import csv
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
# TODO: Add BibTeX citation
|
26 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
27 |
+
_CITATION = """\
|
28 |
+
@article{tydiqa,
|
29 |
+
title = {TyDi QA: A Benchmark for Information-Seeking Question Answering in Typologically Diverse Languages},
|
30 |
+
author = {Jonathan H. Clark and Eunsol Choi and Michael Collins and Dan Garrette and Tom Kwiatkowski and Vitaly Nikolaev and Jennimaria Palomaki}
|
31 |
+
journal = {TACL},
|
32 |
+
year = {2020}
|
33 |
+
}
|
34 |
+
"""
|
35 |
+
|
36 |
+
# TODO: Add description of the dataset here
|
37 |
+
# You can copy an official description
|
38 |
+
_DESCRIPTION = """
|
39 |
+
The english Wikipedia 2019-0201 passage dump that used for xor-tydi retrieval task, available at https://archive.org/download/enwiki-20190201/enwiki-20190201-pages-articles-multistream.xml.bz2
|
40 |
+
"""
|
41 |
+
|
42 |
+
_URLS = {
|
43 |
+
"corpus": {
|
44 |
+
"en_wiki": "en_wiki.tsv",
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
50 |
+
class XorTydi(datasets.GeneratorBasedBuilder):
|
51 |
+
"""TODO: Short description of my dataset."""
|
52 |
+
|
53 |
+
VERSION = datasets.Version("1.1.0")
|
54 |
+
|
55 |
+
# This is an example of a dataset with multiple configurations.
|
56 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
57 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
58 |
+
|
59 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
60 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
61 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
62 |
+
|
63 |
+
# You will be able to load one or the other configurations in the following list with
|
64 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
65 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
66 |
+
BUILDER_CONFIGS = [
|
67 |
+
datasets.BuilderConfig(name="corpus", version=VERSION, description="en wiki passage corpus."),
|
68 |
+
]
|
69 |
+
|
70 |
+
DEFAULT_CONFIG_NAME = "corpus" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
71 |
+
|
72 |
+
def _info(self):
|
73 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
74 |
+
features = datasets.Features(
|
75 |
+
{
|
76 |
+
"docid": datasets.Value("string"),
|
77 |
+
"title": datasets.Value("string"),
|
78 |
+
"text": datasets.Value("string")
|
79 |
+
}
|
80 |
+
)
|
81 |
+
|
82 |
+
return datasets.DatasetInfo(
|
83 |
+
# This is the description that will appear on the datasets page.
|
84 |
+
description=_DESCRIPTION,
|
85 |
+
# This defines the different columns of the dataset and their types
|
86 |
+
homepage='https://github.com/ielab/xor-tydi',
|
87 |
+
features=features, # Here we define them above because they are different between the two configurations
|
88 |
+
citation=_CITATION,
|
89 |
+
)
|
90 |
+
|
91 |
+
def _split_generators(self, dl_manager):
|
92 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
93 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
94 |
+
|
95 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
96 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
97 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
98 |
+
urls = _URLS[self.config.name]['en_wiki']
|
99 |
+
data_dir = dl_manager.download_and_extract(urls)
|
100 |
+
return [
|
101 |
+
datasets.SplitGenerator(
|
102 |
+
name="en_wiki",
|
103 |
+
# These kwargs will be passed to _generate_examples
|
104 |
+
gen_kwargs={
|
105 |
+
"filepath": data_dir,
|
106 |
+
"split": "en_wiki",
|
107 |
+
},
|
108 |
+
),
|
109 |
+
]
|
110 |
+
|
111 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
112 |
+
def _generate_examples(self, filepath, split):
|
113 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
114 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
115 |
+
with open(filepath, encoding="utf-8") as f:
|
116 |
+
for line in f:
|
117 |
+
text_id, text, title = line.strip().split('\t')
|
118 |
+
yield text_id, {"docid": text_id, "title": title, "text": text}
|