Upload 4 files
Browse files- OLD/CoQCat.py +80 -0
- OLD/dev.json +0 -0
- OLD/test.json +0 -0
- OLD/train.json +3 -0
OLD/CoQCat.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CoQA dataset."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
import datasets
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_HOMEPAGE = ""
|
| 10 |
+
|
| 11 |
+
_CITATION = """\
|
| 12 |
+
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
_DESCRIPTION = """\
|
| 16 |
+
CoQCat - Conversational Question Answering in Catalan
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
_TRAIN_FILE = "train.json"
|
| 20 |
+
_DEV_FILE = "dev.json"
|
| 21 |
+
_TEST_FILE = "test.json"
|
| 22 |
+
|
| 23 |
+
class Coqa(datasets.GeneratorBasedBuilder):
|
| 24 |
+
|
| 25 |
+
VERSION = datasets.Version("1.0.0")
|
| 26 |
+
|
| 27 |
+
def _info(self):
|
| 28 |
+
return datasets.DatasetInfo(
|
| 29 |
+
description=_DESCRIPTION,
|
| 30 |
+
features=datasets.Features(
|
| 31 |
+
{
|
| 32 |
+
"source": datasets.Value("string"),
|
| 33 |
+
"story": datasets.Value("string"),
|
| 34 |
+
"questions": datasets.features.Sequence(datasets.Value("string")),
|
| 35 |
+
"answers": datasets.features.Sequence(
|
| 36 |
+
{
|
| 37 |
+
"input_text": datasets.Value("string"),
|
| 38 |
+
"answer_start": datasets.Value("int32"),
|
| 39 |
+
"answer_end": datasets.Value("int32"),
|
| 40 |
+
}
|
| 41 |
+
),
|
| 42 |
+
}
|
| 43 |
+
),
|
| 44 |
+
homepage=_HOMEPAGE,
|
| 45 |
+
citation=_CITATION,
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _split_generators(self, dl_manager):
|
| 50 |
+
"""Returns SplitGenerators."""
|
| 51 |
+
urls_to_download = {
|
| 52 |
+
"train": f"{_TRAIN_FILE}",
|
| 53 |
+
"dev": f"{_DEV_FILE}",
|
| 54 |
+
"test": f"{_TEST_FILE}",
|
| 55 |
+
}
|
| 56 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 57 |
+
|
| 58 |
+
return [
|
| 59 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"], "split": "train"}),
|
| 60 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"], "split": "validation"}),
|
| 61 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"], "split": "test"}),
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
def _generate_examples(self, filepath, split):
|
| 65 |
+
"""Yields examples."""
|
| 66 |
+
with open(filepath, encoding="utf-8") as f:
|
| 67 |
+
data = json.load(f)
|
| 68 |
+
for row in data["data"]:
|
| 69 |
+
questions = [question["input_text"] for question in row["questions"]]
|
| 70 |
+
story = row["story"]
|
| 71 |
+
source = row["source"]
|
| 72 |
+
answers_start = [answer["span_start"] for answer in row["answers"]]
|
| 73 |
+
answers_end = [answer["span_end"] for answer in row["answers"]]
|
| 74 |
+
answers = [answer["input_text"] for answer in row["answers"]]
|
| 75 |
+
yield row["id"], {
|
| 76 |
+
"source": source,
|
| 77 |
+
"story": story,
|
| 78 |
+
"questions": questions,
|
| 79 |
+
"answers": {"input_text": answers, "answer_start": answers_start, "answer_end": answers_end},
|
| 80 |
+
}
|
OLD/dev.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
OLD/test.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
OLD/train.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0e91c9e753e4a747b8aae80f2402df41d2cfaef2add7296e314f57b1ec7e787c
|
| 3 |
+
size 39968225
|