jfrei commited on
Commit
9627eea
1 Parent(s): d5d6cba

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +29 -3
  2. germeval18.py +103 -0
README.md CHANGED
@@ -1,3 +1,29 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ features:
4
+ - name: text
5
+ dtype: string
6
+ - name: coarse
7
+ dtype:
8
+ class_label:
9
+ names:
10
+ '0': OTHER
11
+ '1': OFFENSE
12
+ - name: fine
13
+ dtype:
14
+ class_label:
15
+ names:
16
+ '0': OTHER
17
+ '1': ABUSE
18
+ '2': INSULT
19
+ '3': PROFANITY
20
+ splits:
21
+ - name: train
22
+ num_bytes: 826320
23
+ num_examples: 5009
24
+ - name: test
25
+ num_bytes: 509105
26
+ num_examples: 3532
27
+ download_size: 1282870
28
+ dataset_size: 1335425
29
+ ---
germeval18.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Loader script for the GermEval 18 dataset"""
15
+
16
+
17
+ import csv
18
+ import json
19
+ import os
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """\
25
+ @data{data/0B5VML_2019,
26
+ author = {Wiegand, Michael},
27
+ publisher = {heiDATA},
28
+ title = {{GermEval-2018 Corpus (DE)}},
29
+ year = {2019},
30
+ version = {V1},
31
+ doi = {10.11588/data/0B5VML},
32
+ url = {https://doi.org/10.11588/data/0B5VML}
33
+ }
34
+ """
35
+
36
+ _DESCRIPTION = """\
37
+ This dataset comprises the training and test data (German tweets) from the GermEval 2018 Shared on Offensive Language Detection.
38
+ """
39
+
40
+ _HOMEPAGE = "https://doi.org/10.11588/data/0B5VML"
41
+
42
+ _LICENSE = "CC-BY-4.0 Deed"
43
+
44
+ # The files are pulled from the official GitHub repository.
45
+ # https://github.com/uds-lsv/GermEval-2018-Data
46
+ # We use the hashed URL from master branch / June 3th 2024.
47
+ _URLS = {
48
+ "germeval18.test.txt": "https://raw.githubusercontent.com/uds-lsv/GermEval-2018-Data/9877472d39523effd54cd079b4c61157ed141508/germeval2018.test.txt",
49
+ "germeval18.train.txt": "https://raw.githubusercontent.com/uds-lsv/GermEval-2018-Data/9877472d39523effd54cd079b4c61157ed141508/germeval2018.training.txt",
50
+ }
51
+
52
+ class GermEval18Dataset(datasets.GeneratorBasedBuilder):
53
+ """The GermEval18 dataset"""
54
+
55
+ VERSION = datasets.Version("1.1.0")
56
+
57
+ def _info(self):
58
+ features = datasets.Features(
59
+ {
60
+ "text": datasets.Value("string"),
61
+ 'coarse': datasets.ClassLabel(num_classes=2, names=['OTHER', 'OFFENSE'], names_file=None, id=None),
62
+ 'fine': datasets.ClassLabel(num_classes=4, names=['OTHER', 'ABUSE', 'INSULT', 'PROFANITY'], names_file=None, id=None),
63
+ }
64
+ )
65
+ return datasets.DatasetInfo(
66
+ description=_DESCRIPTION,
67
+ features=features,
68
+ homepage=_HOMEPAGE,
69
+ license=_LICENSE,
70
+ citation=_CITATION,
71
+ )
72
+
73
+ def _split_generators(self, dl_manager):
74
+ downloaded_files = dl_manager.download(_URLS)
75
+ print(downloaded_files)
76
+ return [
77
+ datasets.SplitGenerator(
78
+ name=datasets.Split.TRAIN,
79
+ gen_kwargs={
80
+ "filepath": downloaded_files["germeval18.train.txt"],
81
+ "split": "train",
82
+ },
83
+ ),
84
+ datasets.SplitGenerator(
85
+ name=datasets.Split.TEST,
86
+ # These kwargs will be passed to _generate_examples
87
+ gen_kwargs={
88
+ "filepath": downloaded_files["germeval18.test.txt"],
89
+ "split": "test"
90
+ },
91
+ ),
92
+ ]
93
+
94
+ def _generate_examples(self, filepath, split):
95
+ with open(filepath, encoding="utf-8") as f:
96
+ for key, row in enumerate(f):
97
+ # Every line only has two "\t" tabs.
98
+ data_text, lbl_coarse, lbl_fine = row.rstrip().split("\t")
99
+ yield key, {
100
+ "text": data_text,
101
+ "coarse": lbl_coarse,
102
+ "fine": lbl_fine,
103
+ }