Datasets:
Commit
·
3eda655
1
Parent(s):
f11612e
draft
Browse files- README.md +28 -0
- on_the_books.py +81 -0
README.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1 |
---
|
2 |
license: cc-by-3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
1 |
---
|
2 |
license: cc-by-3.0
|
3 |
+
dataset_info:
|
4 |
+
features:
|
5 |
+
- name: id
|
6 |
+
dtype: string
|
7 |
+
- name: source
|
8 |
+
dtype: string
|
9 |
+
- name: jim_crow
|
10 |
+
dtype:
|
11 |
+
class_label:
|
12 |
+
names:
|
13 |
+
'0': no_jim_crow
|
14 |
+
'1': jim_crow
|
15 |
+
- name: type
|
16 |
+
dtype: string
|
17 |
+
- name: chapter_num
|
18 |
+
dtype: int32
|
19 |
+
- name: section_num
|
20 |
+
dtype: int32
|
21 |
+
- name: chapter_text
|
22 |
+
dtype: string
|
23 |
+
- name: section_text
|
24 |
+
dtype: string
|
25 |
+
splits:
|
26 |
+
- name: train
|
27 |
+
num_bytes: 2119395
|
28 |
+
num_examples: 1785
|
29 |
+
download_size: 2085196
|
30 |
+
dataset_size: 2119395
|
31 |
---
|
on_the_books.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""On the Books Dataset"""
|
16 |
+
|
17 |
+
import csv
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
_CITATION = """TODO"""
|
23 |
+
|
24 |
+
_DESCRIPTION = """\
|
25 |
+
This file is the training set that was used to train an algorithm to identify Jim Crow laws.
|
26 |
+
It contains laws that are labeled as "Jim Crow" (jim_crow=1) or "Not Jim Crow" (jim_crow=0).
|
27 |
+
The source of the determination is also provided.
|
28 |
+
|
29 |
+
"""
|
30 |
+
|
31 |
+
_HOMEPAGE = "https://onthebooks.lib.unc.edu/2"
|
32 |
+
|
33 |
+
_LICENSE = "CC BY 3.0"
|
34 |
+
|
35 |
+
_URL = "https://cdr.lib.unc.edu/downloads/76537b20b?locale=en"
|
36 |
+
|
37 |
+
|
38 |
+
class OnTheBooks(datasets.GeneratorBasedBuilder):
|
39 |
+
VERSION = datasets.Version("1.1.0")
|
40 |
+
|
41 |
+
def _info(self):
|
42 |
+
features = datasets.Features(
|
43 |
+
{
|
44 |
+
"id": datasets.Value("string"),
|
45 |
+
"source": datasets.Value("string"),
|
46 |
+
"jim_crow": datasets.ClassLabel(names=["no_jim_crow", "jim_crow"]),
|
47 |
+
"type": datasets.Value("string"),
|
48 |
+
"chapter_num": datasets.Value("int32"),
|
49 |
+
"section_num": datasets.Value("int32"),
|
50 |
+
"chapter_text": datasets.Value("string"),
|
51 |
+
"section_text": datasets.Value("string"),
|
52 |
+
}
|
53 |
+
)
|
54 |
+
|
55 |
+
return datasets.DatasetInfo(
|
56 |
+
description=_DESCRIPTION,
|
57 |
+
features=features,
|
58 |
+
supervised_keys=None,
|
59 |
+
homepage=_HOMEPAGE,
|
60 |
+
license=_LICENSE,
|
61 |
+
citation=_CITATION,
|
62 |
+
)
|
63 |
+
|
64 |
+
def _split_generators(self, dl_manager):
|
65 |
+
"""Returns SplitGenerators."""
|
66 |
+
|
67 |
+
data_file = dl_manager.download(_URL)
|
68 |
+
return [
|
69 |
+
datasets.SplitGenerator(
|
70 |
+
name=datasets.Split.TRAIN,
|
71 |
+
gen_kwargs={
|
72 |
+
"filepath": data_file,
|
73 |
+
},
|
74 |
+
),
|
75 |
+
]
|
76 |
+
|
77 |
+
def _generate_examples(self, filepath):
|
78 |
+
"""Yields examples as (key, example) tuples."""
|
79 |
+
with open(filepath, encoding="utf-8") as f:
|
80 |
+
reader = csv.DictReader(f)
|
81 |
+
yield from enumerate(reader)
|