stefan-it commited on
Commit
0da0389
·
verified ·
1 Parent(s): f3647c5

fix: remove dataset loader to prevent "Dataset scripts are no longer supported" error

Browse files
Files changed (1) hide show
  1. germeval2014.py +0 -224
germeval2014.py DELETED
@@ -1,224 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2023 HuggingFace Datasets Authors.
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
-
16
- """GermEval 2014 NER Shared Task"""
17
-
18
-
19
- import json
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- @inproceedings{benikova14:_germev_named_entit_recog_shared_task,
26
- added-at = {2017-04-03T19:29:52.000+0000},
27
- address = {Hildesheim, Germany},
28
- author = {Benikova, Darina and Biemann, Chris and Kisselew, Max and Pad\'o, Sebastian},
29
- biburl = {https://puma.ub.uni-stuttgart.de/bibtex/2132d938a7afe8639e78156fb9d756b20/sp},
30
- booktitle = {Proceedings of the KONVENS GermEval workshop},
31
- interhash = {6cad5d4fdd6a07dbefad4221ba7d8d44},
32
- intrahash = {132d938a7afe8639e78156fb9d756b20},
33
- keywords = {myown workshop},
34
- pages = {104--112},
35
- timestamp = {2017-04-03T17:30:49.000+0000},
36
- title = {{GermEval 2014 Named Entity Recognition Shared Task: Companion Paper}},
37
- year = 2014
38
- }
39
- """
40
-
41
- _LICENSE = """\
42
- By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
43
- """
44
-
45
- _DESCRIPTION = """\
46
- # Introduction
47
-
48
- The GermEval 2014 NER Shared Task is an event that makes available CC-licensed German data with NER annotation with the
49
- goal of significantly advancing the state of the art in German NER and to push the field of NER towards nested
50
- representations of named entities.
51
-
52
- The GermEval 2014 NER Shared Task builds on a new dataset with German Named Entity annotation with the following
53
- properties: The data was sampled from German Wikipedia and News Corpora as a collection of citations. The dataset
54
- covers over 31,000 sentences corresponding to over 590,000 tokens. The NER annotation uses the NoSta-D guidelines,
55
- which extend the Tübingen Treebank guidelines, using four main NER categories with sub-structure, and annotating
56
- embeddings among NEs such as [ORG FC Kickers [LOC Darmstadt]].
57
-
58
- # Dataset
59
-
60
- ## Labels
61
-
62
- ### Fine-grained labels indicating NER subtypes
63
-
64
- German morphology is comparatively productive (at least when compared to
65
- English). There is a considerable amount of word formation through both overt (non-zero) derivation and compounding, in
66
- particular for nouns. This gives rise to morphologically complex words that are not identical to, but stand in a direct
67
- relation to, Named Entities. The Shared Task corpus treats these as NE instances but marks them as special subtypes by
68
- introducing two fine-grained labels: -deriv marks derivations from NEs such as the previously mentioned englisch
69
- (“English”), and -part marks compounds including a NE as a subsequence deutschlandweit (“Germany-wide”).
70
-
71
- ### Embedded markables
72
-
73
- Almost all extant corpora with Named Entity annotation assume that NE annotation is “flat”, that is, each word in the
74
- text can form part of at most one NE chunk. Clearly, this is an oversimplification. Consider the noun phase Technische
75
- Universitat Darmstadt ¨ (“Technical University (of) Darmstadt”). It denotes an organization (label ORG), but also holds
76
- another NE, Darmstadt, which is a location (label LOC). To account for such cases, the Shared Task corpus is annotated
77
- with two levels of Named Entities. It captures at least one level of smaller NEs being embedded in larger NEs.
78
-
79
- ## Statistics
80
-
81
- The data used for the GermEval 2014 NER Shared Task builds on the dataset annotated by (Benikova et al., 2014).
82
- In
83
- this dataset, sentences taken from German Wikipedia articles and online news were used as a collection of citations,
84
- then annotated according to extended NoSta-D guidelines and eventually distributed under the CC-BY license. As already
85
- described above, those guidelines use four main categories with sub-structure and nesting.
86
-
87
- The dataset is distributed contains overall more than 31,000 sentences with over 590,000 tokens. Those were divided in
88
- the following way: the training set consists of 24,000 sentences, the development set of 2,200 sentences and the test
89
- set of 5,100 sentences. The test set labels were not available to the participants until after the deadline. The
90
- distribution of the categories over the whole dataset is shown in Table 1. Care was taken to ensure the even dispersion
91
- of the categories in the subsets. The entire dataset contains over 41,000 NEs, about 7.8% of them embedded in other NEs
92
- (nested NEs), about 11.8% are derivations (deriv) and about 5.6% are parts of NEs concatenated with other words (part).
93
-
94
- ## Format
95
-
96
- The tab-separated format used in this dataset is similar to the CoNLL-Format. As illustrated in Table 2, the format
97
- used in the dataset additionally contains token numbers per sentence in the first column and a comment line indicating
98
- source and data before each sentence. The second column contains the tokens. The third column encodes the outer NE
99
- spans, the fourth column the inner ones. The BIO-scheme was used in order to encode the NE spans. In our challenge,
100
- further nested columns were not considered.
101
-
102
- ## Summary
103
-
104
- In summary, we distinguish between 12 classes of NEs: four main classes PERson, LOCation, ORGanisation, and OTHer and
105
- their subclasses, annotated at two levels (“inner” and “outer” chunks). The challenge of this setup is that while it
106
- technically still allows a simple classification approach it introduces a recursive structure that calls for the
107
- application of more general machine learning or other automatically classifying methods that go beyond plain sequence
108
- tagging.
109
- """
110
-
111
- _VERSION = "1.0.0"
112
- _HOMEPAGE_URL = "https://sites.google.com/site/germeval2014ner/"
113
-
114
-
115
- class GermEval2014Config(datasets.BuilderConfig):
116
- """BuilderConfig for GermEval 2014."""
117
-
118
- def __init__(self, **kwargs):
119
- """BuilderConfig for GermEval 2014.
120
- Args:
121
- **kwargs: keyword arguments forwarded to super.
122
- """
123
- super(GermEval2014Config, self).__init__(**kwargs)
124
-
125
- class GermEval2014(datasets.GeneratorBasedBuilder):
126
- """GermEval 2014 NER Shared Task."""
127
-
128
- BUILDER_CONFIGS = [
129
- GermEval2014Config(
130
- name="germeval2014", version=datasets.Version("1.0.0"), description="GermEval 2014 NER Shared Task "
131
- ),
132
- ]
133
-
134
- def _info(self):
135
- return datasets.DatasetInfo(
136
- description=_DESCRIPTION,
137
- features=datasets.Features(
138
- {
139
- "tokens": datasets.Sequence(datasets.Value("string")),
140
- "ner_tags": datasets.Sequence(
141
- datasets.features.ClassLabel(
142
- names=[
143
- "O",
144
- "B-LOC",
145
- "I-LOC",
146
- "B-LOCderiv",
147
- "I-LOCderiv",
148
- "B-LOCpart",
149
- "I-LOCpart",
150
- "B-ORG",
151
- "I-ORG",
152
- "B-ORGderiv",
153
- "I-ORGderiv",
154
- "B-ORGpart",
155
- "I-ORGpart",
156
- "B-OTH",
157
- "I-OTH",
158
- "B-OTHderiv",
159
- "I-OTHderiv",
160
- "B-OTHpart",
161
- "I-OTHpart",
162
- "B-PER",
163
- "I-PER",
164
- "B-PERderiv",
165
- "I-PERderiv",
166
- "B-PERpart",
167
- "I-PERpart",
168
- ]
169
- )
170
- ),
171
- "ner_t5_output": datasets.Value("string"),
172
- "ner_own_output": datasets.Value("string"),
173
- }
174
- ),
175
- supervised_keys=None,
176
- license=_LICENSE,
177
- homepage=_HOMEPAGE_URL,
178
- citation=_CITATION,
179
- )
180
-
181
- def _split_generators(self, dl_manager):
182
- import flair
183
- from flair.datasets import NER_GERMAN_GERMEVAL
184
- corpus = NER_GERMAN_GERMEVAL()
185
-
186
- return [
187
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"sentences": corpus.train}),
188
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"sentences": corpus.dev}),
189
- datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"sentences": corpus.test}),
190
- ]
191
-
192
- def _generate_examples(self, sentences):
193
- for counter, sentence in enumerate(sentences):
194
- original_spans = sentence.get_spans("ner")
195
- original_tokens = []
196
- original_tags = []
197
-
198
- t5_spans = []
199
- own_spans = []
200
-
201
- for index, token in enumerate(sentence.tokens):
202
- original_tag = "O"
203
- for span in original_spans:
204
- if token in span:
205
- original_tag = "B-" + span.tag if token == span[0] else "I-" + span.tag
206
- original_tokens.append(sentence[index].text)
207
- original_tags.append(original_tag)
208
-
209
- for span in original_spans:
210
- span_text = " ".join(token.text for token in span.tokens)
211
- t5_span = f"{span.tag} : {span_text}"
212
- own_span = f"{span.tag} = {span_text}"
213
- t5_spans.append(t5_span)
214
- own_spans.append(own_span)
215
-
216
- ner_t5_output = " || ".join(t5_spans)
217
- ner_own_output = " || ".join(own_spans)
218
-
219
- yield counter, {
220
- "tokens": original_tokens,
221
- "ner_tags": original_tags,
222
- "ner_t5_output": ner_t5_output,
223
- "ner_own_output": ner_own_output,
224
- }