Datasets:
Tasks:
Question Answering
Modalities:
Text
Sub-tasks:
extractive-qa
Languages:
Japanese
Size:
10K - 100K
ArXiv:
License:
Change documentation and remove unused field
Browse files
JaQuAD.py
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
|
| 4 |
import datasets
|
| 5 |
|
| 6 |
-
|
| 7 |
-
_CITATION = """\
|
| 8 |
@article{SkelterLabsInc:JaQuAD,
|
| 9 |
title = {{JaQuAD}: Japanese Question Answering Dataset for Machine
|
| 10 |
Reading Comprehension},
|
| 11 |
-
author = {Byunghoon
|
| 12 |
-
Kyuhong
|
| 13 |
-
Kyungwon
|
| 14 |
-
Seongjin
|
| 15 |
year = {2022},
|
| 16 |
}
|
| 17 |
-
|
| 18 |
-
_DESCRIPTION =
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
JaQuAD
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
_URL = "https://huggingface.co/datasets/SkelterLabsInc/JaQuAD/raw/main/data/"
|
| 29 |
|
| 30 |
|
| 31 |
class JaQuAD(datasets.GeneratorBasedBuilder):
|
| 32 |
-
|
| 33 |
-
VERSION = datasets.Version("0.1.0")
|
| 34 |
|
| 35 |
def _info(self):
|
| 36 |
-
|
| 37 |
features = datasets.Features({
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
})
|
| 49 |
return datasets.DatasetInfo(
|
| 50 |
description=_DESCRIPTION,
|
|
@@ -56,49 +56,62 @@ class JaQuAD(datasets.GeneratorBasedBuilder):
|
|
| 56 |
|
| 57 |
def _split_generators(self, dl_manager):
|
| 58 |
urls_to_download = {
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
}
|
| 62 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 63 |
return [
|
| 64 |
datasets.SplitGenerator(
|
| 65 |
name=datasets.Split.TRAIN,
|
| 66 |
-
gen_kwargs={
|
| 67 |
),
|
| 68 |
datasets.SplitGenerator(
|
| 69 |
name=datasets.Split.VALIDATION,
|
| 70 |
-
gen_kwargs={
|
| 71 |
),
|
| 72 |
]
|
| 73 |
|
| 74 |
def _generate_examples(self, filepaths):
|
| 75 |
for filename in filepaths:
|
| 76 |
-
with open(filename, encoding='utf-8') as
|
| 77 |
-
jaquad = json.load(
|
| 78 |
for article in jaquad['data']:
|
| 79 |
title = article.get('title', '').strip()
|
| 80 |
for paragraph in article['paragraphs']:
|
| 81 |
context = paragraph['context'].strip()
|
| 82 |
for qa in paragraph['qas']:
|
| 83 |
-
qa_id = qa[
|
| 84 |
-
question = qa[
|
| 85 |
-
question_type = qa[
|
| 86 |
-
|
| 87 |
-
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
| 88 |
-
answer_texts = [answer["text"].strip() for answer in qa["answers"]]
|
| 89 |
-
answer_types = [answer["answer_type"] for answer in qa["answers"]]
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
yield qa_id, {
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
},
|
| 104 |
}
|
|
|
|
| 1 |
+
'''Dataset loading script for JaQuAD.
|
| 2 |
+
We refer to https://huggingface.co/datasets/squad_v2/blob/main/squad_v2.py
|
| 3 |
+
'''
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
|
| 7 |
import datasets
|
| 8 |
|
| 9 |
+
_CITATION = '''
|
|
|
|
| 10 |
@article{SkelterLabsInc:JaQuAD,
|
| 11 |
title = {{JaQuAD}: Japanese Question Answering Dataset for Machine
|
| 12 |
Reading Comprehension},
|
| 13 |
+
author = {Byunghoon So and
|
| 14 |
+
Kyuhong Byun and
|
| 15 |
+
Kyungwon Kang and
|
| 16 |
+
Seongjin Cho},
|
| 17 |
year = {2022},
|
| 18 |
}
|
| 19 |
+
'''
|
| 20 |
+
_DESCRIPTION = '''Japanese Question Answering Dataset (JaQuAD), released in
|
| 21 |
+
2022, is a human-annotated dataset created for Japanese Machine Reading
|
| 22 |
+
Comprehension. JaQuAD is developed to provide a SQuAD-like QA dataset in
|
| 23 |
+
Japanese. JaQuAD contains 39,696 question-answer pairs. Questions and answers
|
| 24 |
+
are manually curated by human annotators. Contexts are collected from Japanese
|
| 25 |
+
Wikipedia articles.
|
| 26 |
+
'''
|
| 27 |
+
_LICENSE = 'CC BY-SA 3.0'
|
| 28 |
+
_HOMEPAGE = 'https://skelterlabs.com/en/'
|
| 29 |
+
_URL = 'https://huggingface.co/datasets/SkelterLabsInc/JaQuAD/raw/main/data/'
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
class JaQuAD(datasets.GeneratorBasedBuilder):
|
| 33 |
+
VERSION = datasets.Version('0.1.0')
|
|
|
|
| 34 |
|
| 35 |
def _info(self):
|
|
|
|
| 36 |
features = datasets.Features({
|
| 37 |
+
'id': datasets.Value('string'),
|
| 38 |
+
'title': datasets.Value('string'),
|
| 39 |
+
'context': datasets.Value('string'),
|
| 40 |
+
'question': datasets.Value('string'),
|
| 41 |
+
'question_type': datasets.Value('string'),
|
| 42 |
+
'answers':
|
| 43 |
+
datasets.features.Sequence({
|
| 44 |
+
'text': datasets.Value('string'),
|
| 45 |
+
'answer_start': datasets.Value('int32'),
|
| 46 |
+
'answer_type': datasets.Value('string'),
|
| 47 |
+
}),
|
| 48 |
})
|
| 49 |
return datasets.DatasetInfo(
|
| 50 |
description=_DESCRIPTION,
|
|
|
|
| 56 |
|
| 57 |
def _split_generators(self, dl_manager):
|
| 58 |
urls_to_download = {
|
| 59 |
+
'train': [
|
| 60 |
+
os.path.join(_URL, f'train/jaquad_train_{i:04d}.json')
|
| 61 |
+
for i in range(30)
|
| 62 |
+
],
|
| 63 |
+
'dev': [
|
| 64 |
+
os.path.join(_URL, f'dev/jaquad_dev_{i:04d}.json')
|
| 65 |
+
for i in range(4)
|
| 66 |
+
],
|
| 67 |
}
|
| 68 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 69 |
return [
|
| 70 |
datasets.SplitGenerator(
|
| 71 |
name=datasets.Split.TRAIN,
|
| 72 |
+
gen_kwargs={'filepaths': downloaded_files['train']},
|
| 73 |
),
|
| 74 |
datasets.SplitGenerator(
|
| 75 |
name=datasets.Split.VALIDATION,
|
| 76 |
+
gen_kwargs={'filepaths': downloaded_files['dev']},
|
| 77 |
),
|
| 78 |
]
|
| 79 |
|
| 80 |
def _generate_examples(self, filepaths):
|
| 81 |
for filename in filepaths:
|
| 82 |
+
with open(filename, encoding='utf-8') as ifile:
|
| 83 |
+
jaquad = json.load(ifile)
|
| 84 |
for article in jaquad['data']:
|
| 85 |
title = article.get('title', '').strip()
|
| 86 |
for paragraph in article['paragraphs']:
|
| 87 |
context = paragraph['context'].strip()
|
| 88 |
for qa in paragraph['qas']:
|
| 89 |
+
qa_id = qa['id']
|
| 90 |
+
question = qa['question'].strip()
|
| 91 |
+
question_type = qa['question_type']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
answer_starts = [
|
| 94 |
+
answer['answer_start']
|
| 95 |
+
for answer in qa['answers']
|
| 96 |
+
]
|
| 97 |
+
answer_texts = [
|
| 98 |
+
answer['text'].strip()
|
| 99 |
+
for answer in qa['answers']
|
| 100 |
+
]
|
| 101 |
+
answer_types = [
|
| 102 |
+
answer['answer_type']
|
| 103 |
+
for answer in qa['answers']
|
| 104 |
+
]
|
| 105 |
|
| 106 |
yield qa_id, {
|
| 107 |
+
'title': title,
|
| 108 |
+
'context': context,
|
| 109 |
+
'question': question,
|
| 110 |
+
'question_type': question_type,
|
| 111 |
+
'id': qa_id,
|
| 112 |
+
'answers': {
|
| 113 |
+
'text': answer_texts,
|
| 114 |
+
'answer_start': answer_starts,
|
| 115 |
+
'answer_type': answer_types,
|
| 116 |
},
|
| 117 |
}
|
README.md
CHANGED
|
@@ -96,7 +96,7 @@ An example of 'validation':
|
|
| 96 |
"question_type": "Multiple sentence reasoning",
|
| 97 |
"answers": {
|
| 98 |
"text": "イタセンパラ",
|
| 99 |
-
"
|
| 100 |
"answer_type": "Object",
|
| 101 |
},
|
| 102 |
},
|
|
@@ -111,7 +111,7 @@ An example of 'validation':
|
|
| 111 |
- `question_type`: a `string` feature.
|
| 112 |
- `answers`: a dictionary feature containing:
|
| 113 |
- `text`: a `string` feature.
|
| 114 |
-
- `
|
| 115 |
- `answer_type`: a `string` feature.
|
| 116 |
|
| 117 |
### Data Splitting
|
|
|
|
| 96 |
"question_type": "Multiple sentence reasoning",
|
| 97 |
"answers": {
|
| 98 |
"text": "イタセンパラ",
|
| 99 |
+
"answer_start": 0,
|
| 100 |
"answer_type": "Object",
|
| 101 |
},
|
| 102 |
},
|
|
|
|
| 111 |
- `question_type`: a `string` feature.
|
| 112 |
- `answers`: a dictionary feature containing:
|
| 113 |
- `text`: a `string` feature.
|
| 114 |
+
- `answer_start`: a `int32` feature.
|
| 115 |
- `answer_type`: a `string` feature.
|
| 116 |
|
| 117 |
### Data Splitting
|