Convert dataset to Parquet
#1
by
davanstrien
HF staff
- opened
- README.md +65 -8
- data/train-00000-of-00007.parquet +3 -0
- data/train-00001-of-00007.parquet +3 -0
- data/train-00002-of-00007.parquet +3 -0
- data/train-00003-of-00007.parquet +3 -0
- data/train-00004-of-00007.parquet +3 -0
- data/train-00005-of-00007.parquet +3 -0
- data/train-00006-of-00007.parquet +3 -0
- dataset_infos.json +0 -1
- hansard_speech.py +0 -161
README.md
CHANGED
@@ -1,24 +1,18 @@
|
|
1 |
---
|
2 |
annotations_creators:
|
3 |
- no-annotation
|
4 |
-
language:
|
5 |
-
- 'en'
|
6 |
language_creators:
|
7 |
- expert-generated
|
|
|
|
|
8 |
license:
|
9 |
- cc-by-4.0
|
10 |
multilinguality:
|
11 |
- monolingual
|
12 |
-
pretty_name: Hansard Speeches
|
13 |
size_categories:
|
14 |
- 1M<n<10M
|
15 |
source_datasets:
|
16 |
- original
|
17 |
-
tags:
|
18 |
-
- speeches
|
19 |
-
- politics
|
20 |
-
- parliament
|
21 |
-
- British
|
22 |
task_categories:
|
23 |
- text-classification
|
24 |
- text-generation
|
@@ -26,6 +20,69 @@ task_ids:
|
|
26 |
- multi-class-classification
|
27 |
- language-modeling
|
28 |
- masked-language-modeling
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
---
|
30 |
|
31 |
# Dataset Card for Hansard speech
|
|
|
1 |
---
|
2 |
annotations_creators:
|
3 |
- no-annotation
|
|
|
|
|
4 |
language_creators:
|
5 |
- expert-generated
|
6 |
+
language:
|
7 |
+
- en
|
8 |
license:
|
9 |
- cc-by-4.0
|
10 |
multilinguality:
|
11 |
- monolingual
|
|
|
12 |
size_categories:
|
13 |
- 1M<n<10M
|
14 |
source_datasets:
|
15 |
- original
|
|
|
|
|
|
|
|
|
|
|
16 |
task_categories:
|
17 |
- text-classification
|
18 |
- text-generation
|
|
|
20 |
- multi-class-classification
|
21 |
- language-modeling
|
22 |
- masked-language-modeling
|
23 |
+
pretty_name: Hansard Speeches
|
24 |
+
tags:
|
25 |
+
- speeches
|
26 |
+
- politics
|
27 |
+
- parliament
|
28 |
+
- British
|
29 |
+
dataset_info:
|
30 |
+
features:
|
31 |
+
- name: id
|
32 |
+
dtype: string
|
33 |
+
- name: speech
|
34 |
+
dtype: string
|
35 |
+
- name: display_as
|
36 |
+
dtype: string
|
37 |
+
- name: party
|
38 |
+
dtype: string
|
39 |
+
- name: constituency
|
40 |
+
dtype: string
|
41 |
+
- name: mnis_id
|
42 |
+
dtype: string
|
43 |
+
- name: date
|
44 |
+
dtype: string
|
45 |
+
- name: time
|
46 |
+
dtype: string
|
47 |
+
- name: colnum
|
48 |
+
dtype: string
|
49 |
+
- name: speech_class
|
50 |
+
dtype: string
|
51 |
+
- name: major_heading
|
52 |
+
dtype: string
|
53 |
+
- name: minor_heading
|
54 |
+
dtype: string
|
55 |
+
- name: oral_heading
|
56 |
+
dtype: string
|
57 |
+
- name: year
|
58 |
+
dtype: string
|
59 |
+
- name: hansard_membership_id
|
60 |
+
dtype: string
|
61 |
+
- name: speakerid
|
62 |
+
dtype: string
|
63 |
+
- name: person_id
|
64 |
+
dtype: string
|
65 |
+
- name: speakername
|
66 |
+
dtype: string
|
67 |
+
- name: url
|
68 |
+
dtype: string
|
69 |
+
- name: government_posts
|
70 |
+
sequence: string
|
71 |
+
- name: opposition_posts
|
72 |
+
sequence: string
|
73 |
+
- name: parliamentary_posts
|
74 |
+
sequence: string
|
75 |
+
splits:
|
76 |
+
- name: train
|
77 |
+
num_bytes: 3398866626
|
78 |
+
num_examples: 2694375
|
79 |
+
download_size: 1479284559
|
80 |
+
dataset_size: 3398866626
|
81 |
+
configs:
|
82 |
+
- config_name: default
|
83 |
+
data_files:
|
84 |
+
- split: train
|
85 |
+
path: data/train-*
|
86 |
---
|
87 |
|
88 |
# Dataset Card for Hansard speech
|
data/train-00000-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:075f2944d3e3b26869ebc3722c7d707aa2bf8c22713ce6e9ea3647cbf8f68f0a
|
3 |
+
size 216610228
|
data/train-00001-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2fbc651ff818785bb396a96f9663e74752eaaa7045b5deb6f0a5f76332a5f7a9
|
3 |
+
size 208073916
|
data/train-00002-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:018ddc8d380ea32e9bbf78e88934e8a4e8226094d959c0a8f035bcc7da655ea8
|
3 |
+
size 216361755
|
data/train-00003-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:496e7e51005ac4235c49a603301142dd9cc03ce00e23688f4fcafc89e3b327db
|
3 |
+
size 224522446
|
data/train-00004-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fb8552dc224d08937531e325726b56b31fbeb9481dc3550035ddf78f489905c6
|
3 |
+
size 223169383
|
data/train-00005-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9f724b7696a1b91b9d544d95e477e7c189ad45c7d241ea4bd404eb507cc5a3ca
|
3 |
+
size 195422018
|
data/train-00006-of-00007.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a7087a04feee93cec71caf3652a0ebb668b41277a43d8768d7e8de893071db9d
|
3 |
+
size 195124813
|
dataset_infos.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"default": {"description": "\nA dataset containing every speech in the House of Commons from May 1979-July 2020.\n", "citation": "@misc{odell, evan_2021, \ntitle={Hansard Speeches 1979-2021: Version 3.1.0}, \nDOI={10.5281/zenodo.4843485}, \nabstractNote={<p>Full details are available at <a href=\"https://evanodell.com/projects/datasets/hansard-data\">https://evanodell.com/projects/datasets/hansard-data</a></p> <p><strong>Version 3.1.0 contains the following changes:</strong></p> <p>- Coverage up to the end of April 2021</p>}, \nnote={This release is an update of previously released datasets. See full documentation for details.}, \npublisher={Zenodo}, \nauthor={Odell, Evan}, \nyear={2021}, \nmonth={May} }\n", "homepage": "https://evanodell.com/projects/datasets/hansard-data/", "license": "Creative Commons Attribution 4.0 International License", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "speech": {"dtype": "string", "id": null, "_type": "Value"}, "display_as": {"dtype": "string", "id": null, "_type": "Value"}, "party": {"dtype": "string", "id": null, "_type": "Value"}, "constituency": {"dtype": "string", "id": null, "_type": "Value"}, "mnis_id": {"dtype": "string", "id": null, "_type": "Value"}, "date": {"dtype": "string", "id": null, "_type": "Value"}, "time": {"dtype": "string", "id": null, "_type": "Value"}, "colnum": {"dtype": "string", "id": null, "_type": "Value"}, "speech_class": {"dtype": "string", "id": null, "_type": "Value"}, "major_heading": {"dtype": "string", "id": null, "_type": "Value"}, "minor_heading": {"dtype": "string", "id": null, "_type": "Value"}, "oral_heading": {"dtype": "string", "id": null, "_type": "Value"}, "year": {"dtype": "string", "id": null, "_type": "Value"}, "hansard_membership_id": {"dtype": "string", "id": null, "_type": "Value"}, "speakerid": {"dtype": "string", "id": null, "_type": "Value"}, "person_id": {"dtype": "string", "id": null, "_type": "Value"}, "speakername": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "government_posts": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "opposition_posts": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "parliamentary_posts": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "hansard_speech", "config_name": "default", "version": {"version_str": "3.1.0", "description": null, "major": 3, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3398866626, "num_examples": 2694375, "dataset_name": "hansard_speech"}}, "download_checksums": {"https://zenodo.org/record/4843485/files/hansard-speeches-v310.csv.zip?download=1": {"num_bytes": 917690644, "checksum": "907289e49058f7127e1c48d468105957992de4105e0dab4875f4b49ca080639c"}, "https://zenodo.org/record/4843485/files/parliamentary_posts.json?download=1": {"num_bytes": 18906072, "checksum": "829292ae9fcfd770dbf24da0a07da42479ce8a008464c48076a8115eb8868e6c"}}, "download_size": 936596716, "post_processing_size": null, "dataset_size": 3398866626, "size_in_bytes": 4335463342}}
|
|
|
|
hansard_speech.py
DELETED
@@ -1,161 +0,0 @@
|
|
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 |
-
"""
|
15 |
-
A dataset containing every speech in the House of Commons from May 1979-July 2020.
|
16 |
-
"""
|
17 |
-
|
18 |
-
import json
|
19 |
-
import os
|
20 |
-
import time
|
21 |
-
import pandas as pd
|
22 |
-
from datetime import datetime
|
23 |
-
import datasets
|
24 |
-
|
25 |
-
_CITATION = """@misc{odell, evan_2021,
|
26 |
-
title={Hansard Speeches 1979-2021: Version 3.1.0},
|
27 |
-
DOI={10.5281/zenodo.4843485},
|
28 |
-
abstractNote={<p>Full details are available at <a href="https://evanodell.com/projects/datasets/hansard-data">https://evanodell.com/projects/datasets/hansard-data</a></p> <p><strong>Version 3.1.0 contains the following changes:</strong></p> <p>- Coverage up to the end of April 2021</p>},
|
29 |
-
note={This release is an update of previously released datasets. See full documentation for details.},
|
30 |
-
publisher={Zenodo},
|
31 |
-
author={Odell, Evan},
|
32 |
-
year={2021},
|
33 |
-
month={May} }
|
34 |
-
"""
|
35 |
-
|
36 |
-
_DESCRIPTION = """
|
37 |
-
A dataset containing every speech in the House of Commons from May 1979-July 2020.
|
38 |
-
"""
|
39 |
-
|
40 |
-
_HOMEPAGE = "https://evanodell.com/projects/datasets/hansard-data/"
|
41 |
-
|
42 |
-
_LICENSE = "Creative Commons Attribution 4.0 International License"
|
43 |
-
|
44 |
-
_URLS = {
|
45 |
-
"csv": "https://zenodo.org/record/4843485/files/hansard-speeches-v310.csv.zip?download=1",
|
46 |
-
"json": "https://zenodo.org/record/4843485/files/parliamentary_posts.json?download=1",
|
47 |
-
}
|
48 |
-
|
49 |
-
fields = [
|
50 |
-
"id",
|
51 |
-
"speech",
|
52 |
-
"display_as",
|
53 |
-
"party",
|
54 |
-
"constituency",
|
55 |
-
"mnis_id",
|
56 |
-
"date",
|
57 |
-
"time",
|
58 |
-
"colnum",
|
59 |
-
"speech_class",
|
60 |
-
"major_heading",
|
61 |
-
"minor_heading",
|
62 |
-
"oral_heading",
|
63 |
-
"year",
|
64 |
-
"hansard_membership_id",
|
65 |
-
"speakerid",
|
66 |
-
"person_id",
|
67 |
-
"speakername",
|
68 |
-
"url",
|
69 |
-
"parliamentary_posts",
|
70 |
-
"opposition_posts",
|
71 |
-
"government_posts",
|
72 |
-
]
|
73 |
-
|
74 |
-
logger = datasets.utils.logging.get_logger(__name__)
|
75 |
-
|
76 |
-
|
77 |
-
class HansardSpeech(datasets.GeneratorBasedBuilder):
|
78 |
-
"""A dataset containing every speech in the House of Commons from May 1979-July 2020."""
|
79 |
-
|
80 |
-
VERSION = datasets.Version("3.1.0")
|
81 |
-
|
82 |
-
def _info(self):
|
83 |
-
features = datasets.Features(
|
84 |
-
{
|
85 |
-
"id": datasets.Value("string"),
|
86 |
-
"speech": datasets.Value("string"),
|
87 |
-
"display_as": datasets.Value("string"),
|
88 |
-
"party": datasets.Value("string"),
|
89 |
-
"constituency": datasets.Value("string"),
|
90 |
-
"mnis_id": datasets.Value("string"),
|
91 |
-
"date": datasets.Value("string"),
|
92 |
-
"time": datasets.Value("string"),
|
93 |
-
"colnum": datasets.Value("string"),
|
94 |
-
"speech_class": datasets.Value("string"),
|
95 |
-
"major_heading": datasets.Value("string"),
|
96 |
-
"minor_heading": datasets.Value("string"),
|
97 |
-
"oral_heading": datasets.Value("string"),
|
98 |
-
"year": datasets.Value("string"),
|
99 |
-
"hansard_membership_id": datasets.Value("string"),
|
100 |
-
"speakerid": datasets.Value("string"),
|
101 |
-
"person_id": datasets.Value("string"),
|
102 |
-
"speakername": datasets.Value("string"),
|
103 |
-
"url": datasets.Value("string"),
|
104 |
-
"government_posts": datasets.Sequence(datasets.Value("string")),
|
105 |
-
"opposition_posts": datasets.Sequence(datasets.Value("string")),
|
106 |
-
"parliamentary_posts": datasets.Sequence(datasets.Value("string")),
|
107 |
-
}
|
108 |
-
)
|
109 |
-
return datasets.DatasetInfo(
|
110 |
-
description=_DESCRIPTION,
|
111 |
-
features=features,
|
112 |
-
homepage=_HOMEPAGE,
|
113 |
-
license=_LICENSE,
|
114 |
-
citation=_CITATION,
|
115 |
-
)
|
116 |
-
|
117 |
-
def _split_generators(self, dl_manager):
|
118 |
-
temp_dir = dl_manager.download_and_extract(_URLS["csv"])
|
119 |
-
csv_file = os.path.join(temp_dir, "hansard-speeches-v310.csv")
|
120 |
-
json_file = dl_manager.download(_URLS["json"])
|
121 |
-
return [
|
122 |
-
datasets.SplitGenerator(
|
123 |
-
name=datasets.Split.TRAIN,
|
124 |
-
# These kwargs will be passed to _generate_examples
|
125 |
-
gen_kwargs={"filepaths": [csv_file, json_file], "split": "train",},
|
126 |
-
),
|
127 |
-
]
|
128 |
-
|
129 |
-
def _generate_examples(self, filepaths, split):
|
130 |
-
logger.warn("\nThis is a large dataset. Please be patient")
|
131 |
-
json_data = pd.read_json(filepaths[1])
|
132 |
-
csv_data_chunks = pd.read_csv(filepaths[0], chunksize=50000, dtype="object")
|
133 |
-
for data_chunk in csv_data_chunks:
|
134 |
-
data_chunk.fillna("", inplace=True)
|
135 |
-
for _, row in data_chunk.iterrows():
|
136 |
-
data_point = {}
|
137 |
-
for field in fields[:-3]:
|
138 |
-
data_point[field] = str(row[field]) if row[field] else ""
|
139 |
-
parl_post_list = []
|
140 |
-
if data_point["mnis_id"] and data_point["date"]:
|
141 |
-
speech_dt = data_point["date"] + " 00:00:00"
|
142 |
-
try:
|
143 |
-
parl_posts = json_data[
|
144 |
-
(json_data["mnis_id"] == int(data_point["mnis_id"]))
|
145 |
-
& (json_data["date"] == speech_dt)
|
146 |
-
]["parliamentary_posts"]
|
147 |
-
if len(parl_posts) > 0:
|
148 |
-
parl_posts = parl_posts.iloc[0]
|
149 |
-
for item in parl_posts:
|
150 |
-
parl_post_list.append(item["parl_post_name"])
|
151 |
-
except Exception as e:
|
152 |
-
logger.warn(
|
153 |
-
f"Data could not be fetched for mnis_id: {data_point['mnis_id']}, date: {data_point['date']}\nError: {repr(e)}"
|
154 |
-
)
|
155 |
-
opp_post = []
|
156 |
-
gov_post = []
|
157 |
-
data_point["government_posts"] = gov_post
|
158 |
-
data_point["opposition_posts"] = opp_post
|
159 |
-
data_point["parliamentary_posts"] = parl_post_list
|
160 |
-
yield data_point["id"], data_point
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|