Datasets:
Tasks:
Question Answering
Modalities:
Text
Formats:
parquet
Sub-tasks:
open-domain-qa
Languages:
English
Size:
10K - 100K
License:
Commit
·
27cb3a4
1
Parent(s):
2abf38b
Delete loading script
Browse files- wiki_qa.py +0 -96
wiki_qa.py
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
"""TODO(wiki_qa): Add a description here."""
|
2 |
-
|
3 |
-
|
4 |
-
import csv
|
5 |
-
import os
|
6 |
-
|
7 |
-
import datasets
|
8 |
-
|
9 |
-
|
10 |
-
# TODO(wiki_qa): BibTeX citation
|
11 |
-
_CITATION = """\
|
12 |
-
@InProceedings{YangYihMeek:EMNLP2015:WikiQA,
|
13 |
-
author = {{Yi}, Yang and {Wen-tau}, Yih and {Christopher} Meek},
|
14 |
-
title = "{WikiQA: A Challenge Dataset for Open-Domain Question Answering}",
|
15 |
-
journal = {Association for Computational Linguistics},
|
16 |
-
year = 2015,
|
17 |
-
doi = {10.18653/v1/D15-1237},
|
18 |
-
pages = {2013–2018},
|
19 |
-
}
|
20 |
-
"""
|
21 |
-
|
22 |
-
# TODO(wiki_qa):
|
23 |
-
_DESCRIPTION = """\
|
24 |
-
Wiki Question Answering corpus from Microsoft
|
25 |
-
"""
|
26 |
-
|
27 |
-
_DATA_URL = "https://download.microsoft.com/download/E/5/f/E5FCFCEE-7005-4814-853D-DAA7C66507E0/WikiQACorpus.zip" # 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=52419'
|
28 |
-
|
29 |
-
|
30 |
-
class WikiQa(datasets.GeneratorBasedBuilder):
|
31 |
-
"""TODO(wiki_qa): Short description of my dataset."""
|
32 |
-
|
33 |
-
# TODO(wiki_qa): Set up version.
|
34 |
-
VERSION = datasets.Version("0.1.0")
|
35 |
-
|
36 |
-
def _info(self):
|
37 |
-
# TODO(wiki_qa): Specifies the datasets.DatasetInfo object
|
38 |
-
return datasets.DatasetInfo(
|
39 |
-
# This is the description that will appear on the datasets page.
|
40 |
-
description=_DESCRIPTION,
|
41 |
-
# datasets.features.FeatureConnectors
|
42 |
-
features=datasets.Features(
|
43 |
-
{
|
44 |
-
"question_id": datasets.Value("string"),
|
45 |
-
"question": datasets.Value("string"),
|
46 |
-
"document_title": datasets.Value("string"),
|
47 |
-
"answer": datasets.Value("string"),
|
48 |
-
"label": datasets.features.ClassLabel(num_classes=2),
|
49 |
-
# These are the features of your dataset like images, labels ...
|
50 |
-
}
|
51 |
-
),
|
52 |
-
# If there's a common (input, target) tuple from the features,
|
53 |
-
# specify them here. They'll be used if as_supervised=True in
|
54 |
-
# builder.as_dataset.
|
55 |
-
supervised_keys=None,
|
56 |
-
# Homepage of the dataset for documentation
|
57 |
-
homepage="https://www.microsoft.com/en-us/download/details.aspx?id=52419",
|
58 |
-
citation=_CITATION,
|
59 |
-
)
|
60 |
-
|
61 |
-
def _split_generators(self, dl_manager):
|
62 |
-
"""Returns SplitGenerators."""
|
63 |
-
# TODO(wiki_qa): Downloads the data and defines the splits
|
64 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to
|
65 |
-
# download and extract URLs
|
66 |
-
dl_dir = dl_manager.download_and_extract(_DATA_URL)
|
67 |
-
dl_dir = os.path.join(dl_dir, "WikiQACorpus")
|
68 |
-
# dl_dir = os.path.join(dl_dir, '')
|
69 |
-
return [
|
70 |
-
datasets.SplitGenerator(
|
71 |
-
name=datasets.Split.TEST, gen_kwargs={"filepath": os.path.join(dl_dir, "WikiQA-test.tsv")}
|
72 |
-
),
|
73 |
-
datasets.SplitGenerator(
|
74 |
-
name=datasets.Split.VALIDATION, gen_kwargs={"filepath": os.path.join(dl_dir, "WikiQA-dev.tsv")}
|
75 |
-
),
|
76 |
-
datasets.SplitGenerator(
|
77 |
-
name=datasets.Split.TRAIN,
|
78 |
-
# These kwargs will be passed to _generate_examples
|
79 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, "WikiQA-train.tsv")},
|
80 |
-
),
|
81 |
-
]
|
82 |
-
|
83 |
-
def _generate_examples(self, filepath):
|
84 |
-
"""Yields examples."""
|
85 |
-
# TODO(wiki_qa): Yields (key, example) tuples from the dataset
|
86 |
-
|
87 |
-
with open(filepath, encoding="utf-8") as f:
|
88 |
-
reader = csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
|
89 |
-
for idx, row in enumerate(reader):
|
90 |
-
yield idx, {
|
91 |
-
"question_id": row["QuestionID"],
|
92 |
-
"question": row["Question"],
|
93 |
-
"document_title": row["DocumentTitle"],
|
94 |
-
"answer": row["Sentence"],
|
95 |
-
"label": row["Label"],
|
96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|