albertvillanova HF staff commited on
Commit
182be44
1 Parent(s): 4052ec6

Delete loading script

Browse files
Files changed (1) hide show
  1. crime_and_punish.py +0 -59
crime_and_punish.py DELETED
@@ -1,59 +0,0 @@
1
- import datasets
2
-
3
-
4
- _DESCRIPTION = """\
5
-
6
- """
7
- _URL = "https://www.gutenberg.org/files/2554/2554-h/2554-h.htm"
8
- _DATA_URL = "https://raw.githubusercontent.com/patrickvonplaten/datasets/master/crime_and_punishment.txt"
9
-
10
-
11
- class CrimeAndPunish(datasets.GeneratorBasedBuilder):
12
- def _info(self):
13
- return datasets.DatasetInfo(
14
- # This is the description that will appear on the datasets page.
15
- description=_DESCRIPTION,
16
- # datasets.features.FeatureConnectors
17
- features=datasets.Features(
18
- {
19
- "line": datasets.Value("string"),
20
- }
21
- ),
22
- # If there's a common (input, target) tuple from the features,
23
- # specify them here. They'll be used if as_supervised=True in
24
- # builder.as_dataset.
25
- supervised_keys=None,
26
- homepage=_URL,
27
- )
28
-
29
- def _split_generators(self, dl_manager):
30
- """Returns SplitGenerators."""
31
-
32
- data = dl_manager.download_and_extract(_DATA_URL)
33
-
34
- return [
35
- datasets.SplitGenerator(
36
- name=datasets.Split.TRAIN,
37
- gen_kwargs={"data_file": data, "split": "train"},
38
- ),
39
- ]
40
-
41
- def _generate_examples(self, data_file, split):
42
-
43
- with open(data_file, "rb") as f:
44
- id_counter = 0
45
- add_text = False
46
- crime_and_punishment_occ_counter = 0
47
-
48
- for line in f:
49
- line = line.decode("UTF-8")
50
- if "CRIME AND PUNISHMENT" in line:
51
- crime_and_punishment_occ_counter += 1
52
- add_text = crime_and_punishment_occ_counter == 3
53
- if "End of Project" in line:
54
- add_text = False
55
-
56
- if add_text is True:
57
- result = {"line": line}
58
- id_counter += 1
59
- yield id_counter, result