ErickP commited on
Commit
d3242fd
1 Parent(s): 6a60c56

Upload IndiaPoliceEvents.py

Browse files
Files changed (1) hide show
  1. IndiaPoliceEvents.py +60 -0
IndiaPoliceEvents.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import, division, print_function
2
+
3
+ import datasets
4
+
5
+
6
+ _URLs = {
7
+ "train": "train.tsv",
8
+ "valid": "valid.tsv",
9
+ "test": "test.tsv",
10
+ }
11
+
12
+
13
+ class RottenTomato(datasets.GeneratorBasedBuilder):
14
+ def _info(self):
15
+ return datasets.DatasetInfo(
16
+ description="MR Dataset",
17
+ features=datasets.Features(
18
+ {
19
+ "text": datasets.Value("string"),
20
+ "label": datasets.features.ClassLabel(names=['kill', 'arrest', 'fail to act', 'force']),
21
+ }
22
+ ),
23
+ supervised_keys=None,
24
+ license="",
25
+ homepage="",
26
+ citation="",
27
+ )
28
+
29
+ def _split_generators(self, dl_manager):
30
+ downloaded_files = dl_manager.download_and_extract(_URLs)
31
+
32
+ return [
33
+ datasets.SplitGenerator(
34
+ name=datasets.Split.TRAIN,
35
+ gen_kwargs={
36
+ "filepath": downloaded_files["train"],
37
+ }
38
+ ),
39
+ datasets.SplitGenerator(
40
+ name=datasets.Split.VALIDATION,
41
+ gen_kwargs={
42
+ "filepath": downloaded_files["valid"],
43
+ }
44
+ ),
45
+ datasets.SplitGenerator(
46
+ name=datasets.Split.TEST,
47
+ gen_kwargs={
48
+ "filepath": downloaded_files["test"],
49
+ }
50
+ ),
51
+ ]
52
+
53
+ def _generate_examples(self, filepath):
54
+
55
+ with open(filepath, "r", encoding='ISO-8859-1') as f:
56
+ for idx, line in enumerate(f):
57
+ text, label = line.split("\t")
58
+ text = " ".join(text.split()[:1000])
59
+
60
+ yield idx, {"text": text.strip(), "label": label.strip()}