Datasets:
Commit
•
f3e1b99
1
Parent(s):
d78c52f
Delete loading script
Browse files- on_the_books.py +0 -81
on_the_books.py
DELETED
@@ -1,81 +0,0 @@
|
|
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/"
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|