Upload 5 files
Browse files- JJQA.py +177 -0
- README.md +47 -1
- hf_q_a.json +0 -0
- hf_song.json +0 -0
- hf_song_indx.json +187 -0
JJQA.py
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
https://github.com/bebetterest/JJQA
|
29 |
+
"""
|
30 |
+
|
31 |
+
# TODO: Add description of the dataset here
|
32 |
+
# You can copy an official description
|
33 |
+
_DESCRIPTION = """\
|
34 |
+
JJQA: a Chinese QA dataset on the lyrics of JJ Lin's songs.
|
35 |
+
"""
|
36 |
+
|
37 |
+
# TODO: Add a link to an official homepage for the dataset here
|
38 |
+
_HOMEPAGE = "https://github.com/bebetterest/JJQA"
|
39 |
+
|
40 |
+
# TODO: Add the licence for the dataset here if you can find it
|
41 |
+
_LICENSE = "Apache-2.0 license"
|
42 |
+
|
43 |
+
# TODO: Add link to the official dataset URLs here
|
44 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
45 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
46 |
+
_URLS = {
|
47 |
+
"qa": "hf_q_a.json",
|
48 |
+
"song": "hf_song.json",
|
49 |
+
"song_index": "hf_song_indx.json"
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
54 |
+
class JJQA(datasets.GeneratorBasedBuilder):
|
55 |
+
"""TODO: Short description of my dataset."""
|
56 |
+
|
57 |
+
VERSION = datasets.Version("0.0.1")
|
58 |
+
|
59 |
+
# This is an example of a dataset with multiple configurations.
|
60 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
61 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
62 |
+
|
63 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
64 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
65 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
66 |
+
|
67 |
+
# You will be able to load one or the other configurations in the following list with
|
68 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
69 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
70 |
+
BUILDER_CONFIGS = [
|
71 |
+
datasets.BuilderConfig(name="qa", version=VERSION, description="This part of my dataset covers a first domain"),
|
72 |
+
datasets.BuilderConfig(name="song", version=VERSION, description="This part of my dataset covers a second domain"),
|
73 |
+
datasets.BuilderConfig(name="song_index", version=VERSION, description="This part of my dataset covers a first domain"),
|
74 |
+
]
|
75 |
+
|
76 |
+
DEFAULT_CONFIG_NAME = "qa" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
77 |
+
|
78 |
+
def _info(self):
|
79 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
80 |
+
if self.config.name == "qa": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
81 |
+
description=_DESCRIPTION+" This is the field with Q&As."
|
82 |
+
features = datasets.Features(
|
83 |
+
{
|
84 |
+
"q": datasets.Value("string"),
|
85 |
+
"a": datasets.Value("string"),
|
86 |
+
"rf": datasets.Value("string"),
|
87 |
+
"song_title": datasets.Value("string"),
|
88 |
+
"song_id": datasets.Value("string"),
|
89 |
+
"id": datasets.Value("string"),
|
90 |
+
# These are the features of your dataset like images, labels ...
|
91 |
+
}
|
92 |
+
)
|
93 |
+
elif self.config.name == "song":
|
94 |
+
description=_DESCRIPTION+" This is the field with songs."
|
95 |
+
features = datasets.Features(
|
96 |
+
{
|
97 |
+
"id": datasets.Value("string"),
|
98 |
+
"title": datasets.Value("string"),
|
99 |
+
"name": datasets.Value("string"),
|
100 |
+
"lyric": datasets.Value("string"),
|
101 |
+
# These are the features of your dataset like images, labels ...
|
102 |
+
}
|
103 |
+
)
|
104 |
+
else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
105 |
+
description=_DESCRIPTION+" This is the field with a song_id-index dict."
|
106 |
+
features = datasets.Features(
|
107 |
+
{
|
108 |
+
"dic": datasets.Value("string"),
|
109 |
+
# These are the features of your dataset like images, labels ...
|
110 |
+
}
|
111 |
+
)
|
112 |
+
|
113 |
+
return datasets.DatasetInfo(
|
114 |
+
# This is the description that will appear on the datasets page.
|
115 |
+
description=description,
|
116 |
+
# This defines the different columns of the dataset and their types
|
117 |
+
features=features, # Here we define them above because they are different between the two configurations
|
118 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
119 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
120 |
+
# supervised_keys=("sentence", "label"),
|
121 |
+
# Homepage of the dataset for documentation
|
122 |
+
homepage=_HOMEPAGE,
|
123 |
+
# License for the dataset if available
|
124 |
+
license=_LICENSE,
|
125 |
+
# Citation for the dataset
|
126 |
+
citation=_CITATION,
|
127 |
+
)
|
128 |
+
|
129 |
+
def _split_generators(self, dl_manager):
|
130 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
131 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
132 |
+
|
133 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
134 |
+
# 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.
|
135 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
136 |
+
urls = _URLS[self.config.name]
|
137 |
+
data_dir = dl_manager.download_and_extract(urls)
|
138 |
+
return [
|
139 |
+
datasets.SplitGenerator(
|
140 |
+
name=datasets.Split.TRAIN,
|
141 |
+
# These kwargs will be passed to _generate_examples
|
142 |
+
gen_kwargs={
|
143 |
+
"filepath": urls,
|
144 |
+
# "split": "train",
|
145 |
+
},
|
146 |
+
)
|
147 |
+
]
|
148 |
+
|
149 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
150 |
+
def _generate_examples(self, filepath):
|
151 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
152 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
153 |
+
tmp=None
|
154 |
+
with open(filepath, encoding="utf-8") as f:
|
155 |
+
tmp=json.load(f)["data"]
|
156 |
+
if(self.config.name=="qa"):
|
157 |
+
for key, row in enumerate(tmp):
|
158 |
+
yield key, {
|
159 |
+
"q": row["q"],
|
160 |
+
"a": row["a"],
|
161 |
+
"rf": row["rf"],
|
162 |
+
"song_title": row["song_title"],
|
163 |
+
"song_id": row["song_id"],
|
164 |
+
"id": row["id"],
|
165 |
+
}
|
166 |
+
elif(self.config.name=="song"):
|
167 |
+
for key, row in enumerate(tmp):
|
168 |
+
yield key, {
|
169 |
+
"id": row["id"],
|
170 |
+
"title": row["title"],
|
171 |
+
"name": row["name"],
|
172 |
+
"lyric": row["lyric"],
|
173 |
+
}
|
174 |
+
else:
|
175 |
+
yield 0,{
|
176 |
+
"dic":json.dumps(tmp)
|
177 |
+
}
|
README.md
CHANGED
@@ -1,3 +1,49 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
1 |
---
|
2 |
+
dataset_info:
|
3 |
+
- config_name: qa
|
4 |
+
features:
|
5 |
+
- name: q
|
6 |
+
dtype: string
|
7 |
+
- name: a
|
8 |
+
dtype: string
|
9 |
+
- name: rf
|
10 |
+
dtype: string
|
11 |
+
- name: song_title
|
12 |
+
dtype: string
|
13 |
+
- name: song_id
|
14 |
+
dtype: string
|
15 |
+
- name: id
|
16 |
+
dtype: string
|
17 |
+
splits:
|
18 |
+
- name: train
|
19 |
+
num_bytes: 67824
|
20 |
+
num_examples: 648
|
21 |
+
download_size: 134589
|
22 |
+
dataset_size: 67824
|
23 |
+
- config_name: song
|
24 |
+
features:
|
25 |
+
- name: id
|
26 |
+
dtype: string
|
27 |
+
- name: title
|
28 |
+
dtype: string
|
29 |
+
- name: name
|
30 |
+
dtype: string
|
31 |
+
- name: lyric
|
32 |
+
dtype: string
|
33 |
+
splits:
|
34 |
+
- name: train
|
35 |
+
num_bytes: 253605
|
36 |
+
num_examples: 181
|
37 |
+
download_size: 276024
|
38 |
+
dataset_size: 253605
|
39 |
+
- config_name: song_index
|
40 |
+
features:
|
41 |
+
- name: dic
|
42 |
+
dtype: string
|
43 |
+
splits:
|
44 |
+
- name: train
|
45 |
+
num_bytes: 2872
|
46 |
+
num_examples: 1
|
47 |
+
download_size: 4168
|
48 |
+
dataset_size: 2872
|
49 |
---
|
hf_q_a.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
hf_song.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
hf_song_indx.json
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"data": [
|
3 |
+
{
|
4 |
+
"380929182": 0,
|
5 |
+
"410919": 1,
|
6 |
+
"410780": 2,
|
7 |
+
"330621482": 3,
|
8 |
+
"102388816": 4,
|
9 |
+
"233346345": 5,
|
10 |
+
"105393425": 6,
|
11 |
+
"102388811": 7,
|
12 |
+
"240180882": 8,
|
13 |
+
"648227": 9,
|
14 |
+
"648242": 10,
|
15 |
+
"330621488": 11,
|
16 |
+
"101019": 12,
|
17 |
+
"105163752": 13,
|
18 |
+
"3584623": 14,
|
19 |
+
"102388813": 15,
|
20 |
+
"102388809": 16,
|
21 |
+
"764257": 17,
|
22 |
+
"648231": 18,
|
23 |
+
"95263": 19,
|
24 |
+
"648246": 20,
|
25 |
+
"447252": 21,
|
26 |
+
"102388815": 22,
|
27 |
+
"103612": 23,
|
28 |
+
"410783": 24,
|
29 |
+
"101018": 25,
|
30 |
+
"105095766": 26,
|
31 |
+
"101014": 27,
|
32 |
+
"107360759": 28,
|
33 |
+
"101659149": 29,
|
34 |
+
"126693781": 30,
|
35 |
+
"212664070": 31,
|
36 |
+
"105393422": 32,
|
37 |
+
"764255": 33,
|
38 |
+
"212664075": 34,
|
39 |
+
"95270": 35,
|
40 |
+
"447346": 36,
|
41 |
+
"480878": 37,
|
42 |
+
"105388644": 38,
|
43 |
+
"101659148": 39,
|
44 |
+
"95286": 40,
|
45 |
+
"236314334": 41,
|
46 |
+
"410781": 42,
|
47 |
+
"257287": 43,
|
48 |
+
"213773480": 44,
|
49 |
+
"2479366": 45,
|
50 |
+
"648232": 46,
|
51 |
+
"105393420": 47,
|
52 |
+
"405007726": 48,
|
53 |
+
"290290285": 49,
|
54 |
+
"313271033": 50,
|
55 |
+
"102388807": 51,
|
56 |
+
"95287": 52,
|
57 |
+
"5123824": 53,
|
58 |
+
"330621489": 54,
|
59 |
+
"405007732": 55,
|
60 |
+
"447254": 56,
|
61 |
+
"212656958": 57,
|
62 |
+
"101659147": 58,
|
63 |
+
"103611": 59,
|
64 |
+
"237773551": 60,
|
65 |
+
"9063002": 61,
|
66 |
+
"95268": 62,
|
67 |
+
"212664073": 63,
|
68 |
+
"277438634": 64,
|
69 |
+
"764262": 65,
|
70 |
+
"447258": 66,
|
71 |
+
"95290": 67,
|
72 |
+
"101020": 68,
|
73 |
+
"225903007": 69,
|
74 |
+
"103602": 70,
|
75 |
+
"95293": 71,
|
76 |
+
"330621486": 72,
|
77 |
+
"330621484": 73,
|
78 |
+
"5063367": 74,
|
79 |
+
"279701424": 75,
|
80 |
+
"5063373": 76,
|
81 |
+
"102388810": 77,
|
82 |
+
"180065": 78,
|
83 |
+
"165429": 79,
|
84 |
+
"648244": 80,
|
85 |
+
"95292": 81,
|
86 |
+
"405007724": 82,
|
87 |
+
"105710031": 83,
|
88 |
+
"434985": 84,
|
89 |
+
"330621481": 85,
|
90 |
+
"125875386": 86,
|
91 |
+
"102388814": 87,
|
92 |
+
"95262": 88,
|
93 |
+
"102388808": 89,
|
94 |
+
"405007731": 90,
|
95 |
+
"124688346": 91,
|
96 |
+
"405007727": 92,
|
97 |
+
"102212094": 93,
|
98 |
+
"105393416": 94,
|
99 |
+
"103608": 95,
|
100 |
+
"434017": 96,
|
101 |
+
"417100": 97,
|
102 |
+
"104309549": 98,
|
103 |
+
"103610": 99,
|
104 |
+
"405007733": 100,
|
105 |
+
"95265": 101,
|
106 |
+
"410773": 102,
|
107 |
+
"330621487": 103,
|
108 |
+
"212664068": 104,
|
109 |
+
"393959376": 105,
|
110 |
+
"212664076": 106,
|
111 |
+
"5063369": 107,
|
112 |
+
"330621480": 108,
|
113 |
+
"101795110": 109,
|
114 |
+
"101015": 110,
|
115 |
+
"212664071": 111,
|
116 |
+
"102415346": 112,
|
117 |
+
"95288": 113,
|
118 |
+
"95271": 114,
|
119 |
+
"877021": 115,
|
120 |
+
"101232": 116,
|
121 |
+
"182161": 117,
|
122 |
+
"764263": 118,
|
123 |
+
"211884290": 119,
|
124 |
+
"764258": 120,
|
125 |
+
"1219534": 121,
|
126 |
+
"764260": 122,
|
127 |
+
"447260": 123,
|
128 |
+
"212664072": 124,
|
129 |
+
"233086480": 125,
|
130 |
+
"102943286": 126,
|
131 |
+
"7083998": 127,
|
132 |
+
"648230": 128,
|
133 |
+
"95269": 129,
|
134 |
+
"371679750": 130,
|
135 |
+
"410776": 131,
|
136 |
+
"273270232": 132,
|
137 |
+
"95291": 133,
|
138 |
+
"105393411": 134,
|
139 |
+
"3584622": 135,
|
140 |
+
"212664077": 136,
|
141 |
+
"103518": 137,
|
142 |
+
"405007728": 138,
|
143 |
+
"410775": 139,
|
144 |
+
"330621483": 140,
|
145 |
+
"279701423": 141,
|
146 |
+
"105704752": 142,
|
147 |
+
"103605": 143,
|
148 |
+
"764259": 144,
|
149 |
+
"616680": 145,
|
150 |
+
"5063375": 146,
|
151 |
+
"102388806": 147,
|
152 |
+
"103607": 148,
|
153 |
+
"9087424": 149,
|
154 |
+
"333777105": 150,
|
155 |
+
"648233": 151,
|
156 |
+
"5063370": 152,
|
157 |
+
"5063372": 153,
|
158 |
+
"124688347": 154,
|
159 |
+
"5063371": 155,
|
160 |
+
"95272": 156,
|
161 |
+
"764261": 157,
|
162 |
+
"405007735": 158,
|
163 |
+
"764256": 159,
|
164 |
+
"105393423": 160,
|
165 |
+
"447256": 161,
|
166 |
+
"125432256": 162,
|
167 |
+
"737740": 163,
|
168 |
+
"101017": 164,
|
169 |
+
"405007729": 165,
|
170 |
+
"2650630": 166,
|
171 |
+
"126692705": 167,
|
172 |
+
"279701422": 168,
|
173 |
+
"764265": 169,
|
174 |
+
"764254": 170,
|
175 |
+
"105393417": 171,
|
176 |
+
"648243": 172,
|
177 |
+
"447259": 173,
|
178 |
+
"95284": 174,
|
179 |
+
"405007725": 175,
|
180 |
+
"410785": 176,
|
181 |
+
"105388642": 177,
|
182 |
+
"279701421": 178,
|
183 |
+
"279701420": 179,
|
184 |
+
"101013": 180
|
185 |
+
}
|
186 |
+
]
|
187 |
+
}
|