Basirudin commited on
Commit
540583d
·
verified ·
1 Parent(s): 69e21b8

Delete aka_generic_ner.py

Browse files
Files changed (1) hide show
  1. aka_generic_ner.py +0 -247
aka_generic_ner.py DELETED
@@ -1,247 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 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
- # Lint as: python3
17
- """Introduction to the CoNLL-2003 Shared Task: Language-Independent Named Entity Recognition"""
18
-
19
- import os
20
-
21
- import datasets
22
-
23
-
24
- logger = datasets.logging.get_logger(__name__)
25
-
26
-
27
- _CITATION = """\
28
- @inproceedings{tjong-kim-sang-de-meulder-2003-introduction,
29
- title = "Introduction to the {C}o{NLL}-2003 Shared Task: Language-Independent Named Entity Recognition",
30
- author = "Tjong Kim Sang, Erik F. and
31
- De Meulder, Fien",
32
- booktitle = "Proceedings of the Seventh Conference on Natural Language Learning at {HLT}-{NAACL} 2003",
33
- year = "2003",
34
- url = "https://www.aclweb.org/anthology/W03-0419",
35
- pages = "142--147",
36
- }
37
- """
38
-
39
- _DESCRIPTION = """\
40
- The shared task of CoNLL-2003 concerns language-independent named entity recognition. We will concentrate on
41
- four types of named entities: persons, locations, organizations and names of miscellaneous entities that do
42
- not belong to the previous three groups.
43
- The CoNLL-2003 shared task data files contain four columns separated by a single space. Each word has been put on
44
- a separate line and there is an empty line after each sentence. The first item on each line is a word, the second
45
- a part-of-speech (POS) tag, the third a syntactic chunk tag and the fourth the named entity tag. The chunk tags
46
- and the named entity tags have the format I-TYPE which means that the word is inside a phrase of type TYPE. Only
47
- if two phrases of the same type immediately follow each other, the first word of the second phrase will have tag
48
- B-TYPE to show that it starts a new phrase. A word with tag O is not part of a phrase. Note the dataset uses IOB2
49
- tagging scheme, whereas the original dataset uses IOB1.
50
- For more details see https://www.clips.uantwerpen.be/conll2003/ner/ and https://www.aclweb.org/anthology/W03-0419
51
- """
52
-
53
- _URL = "https://embraceletsupply.com/wp-content/uploads/2024/04/aka2024.zip" #"https://data.deepai.org/conll2003.zip"
54
- _TRAINING_FILE = "train.txt"
55
- _DEV_FILE = "valid.txt"
56
- _TEST_FILE = "test.txt"
57
-
58
-
59
- class AkaGenericNerConfig(datasets.BuilderConfig):
60
- """BuilderConfig for AkaGenericNer"""
61
-
62
- def __init__(self, **kwargs):
63
- """BuilderConfig forAkaGenericNer.
64
- Args:
65
- **kwargs: keyword arguments forwarded to super.
66
- """
67
- super(AkaGenericNerConfig, self).__init__(**kwargs)
68
-
69
-
70
- class AkaGenericNer(datasets.GeneratorBasedBuilder):
71
- """AkaGenericNer dataset."""
72
-
73
- BUILDER_CONFIGS = [
74
- AkaGenericNerConfig(name="aka2024", version=datasets.Version("1.0.0"), description="AKA Generic NER dataset"),
75
- ]
76
-
77
- def _info(self):
78
- return datasets.DatasetInfo(
79
- description=_DESCRIPTION,
80
- features=datasets.Features(
81
- {
82
- "id": datasets.Value("string"),
83
- "tokens": datasets.Sequence(datasets.Value("string")),
84
- "pos_tags": datasets.Sequence(
85
- datasets.features.ClassLabel(
86
- names=[
87
- '"',
88
- "''",
89
- "#",
90
- "$",
91
- "(",
92
- ")",
93
- ",",
94
- ".",
95
- ":",
96
- "``",
97
- "CC",
98
- "CD",
99
- "DT",
100
- "EX",
101
- "FW",
102
- "IN",
103
- "JJ",
104
- "JJR",
105
- "JJS",
106
- "LS",
107
- "MD",
108
- "NN",
109
- "NNP",
110
- "NNPS",
111
- "NNS",
112
- "NN|SYM",
113
- "PDT",
114
- "POS",
115
- "PRP",
116
- "PRP$",
117
- "RB",
118
- "RBR",
119
- "RBS",
120
- "RP",
121
- "SYM",
122
- "TO",
123
- "UH",
124
- "VB",
125
- "VBD",
126
- "VBG",
127
- "VBN",
128
- "VBP",
129
- "VBZ",
130
- "WDT",
131
- "WP",
132
- "WP$",
133
- "WRB",
134
- ]
135
- )
136
- ),
137
- "chunk_tags": datasets.Sequence(
138
- datasets.features.ClassLabel(
139
- names=[
140
- "O",
141
- "B-ADJP",
142
- "I-ADJP",
143
- "B-ADVP",
144
- "I-ADVP",
145
- "B-CONJP",
146
- "I-CONJP",
147
- "B-INTJ",
148
- "I-INTJ",
149
- "B-LST",
150
- "I-LST",
151
- "B-NP",
152
- "I-NP",
153
- "B-PP",
154
- "I-PP",
155
- "B-PRT",
156
- "I-PRT",
157
- "B-SBAR",
158
- "I-SBAR",
159
- "B-UCP",
160
- "I-UCP",
161
- "B-VP",
162
- "I-VP",
163
- ]
164
- )
165
- ),
166
- "ner_tags": datasets.Sequence(
167
- datasets.features.ClassLabel(
168
- names=[
169
- "O",
170
- "B-KPI",
171
- "I-KPI",
172
- "B-DIM",
173
- "I-DIM",
174
- "B-FSC",
175
- "I-FSC",
176
- "B-FWEL",
177
- "I-FWEL",
178
- "B-FRIG",
179
- "I-FRIG",
180
- "B-FDEP",
181
- "I-FDEP",
182
- "B-MISC",
183
- "I-MISC",
184
- ]
185
- )
186
- ),
187
- }
188
- ),
189
- supervised_keys=None,
190
- homepage="https://www.aclweb.org/anthology/W03-0419/",
191
- citation=_CITATION,
192
- )
193
-
194
- def _split_generators(self, dl_manager):
195
- """Returns SplitGenerators."""
196
- downloaded_file = dl_manager.download_and_extract(_URL)
197
- data_files = {
198
- "train": os.path.join(downloaded_file, _TRAINING_FILE),
199
- "dev": os.path.join(downloaded_file, _DEV_FILE),
200
- "test": os.path.join(downloaded_file, _TEST_FILE),
201
- }
202
-
203
- return [
204
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_files["train"]}),
205
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_files["dev"]}),
206
- datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_files["test"]}),
207
- ]
208
-
209
- def _generate_examples(self, filepath):
210
- logger.info("⏳ Generating examples from = %s", filepath)
211
- with open(filepath, encoding="utf-8") as f:
212
- guid = 0
213
- tokens = []
214
- pos_tags = []
215
- chunk_tags = []
216
- ner_tags = []
217
- for line in f:
218
- if line.startswith("-DOCSTART-") or line == "" or line == "\n":
219
- if tokens:
220
- yield guid, {
221
- "id": str(guid),
222
- "tokens": tokens,
223
- "pos_tags": pos_tags,
224
- "chunk_tags": chunk_tags,
225
- "ner_tags": ner_tags,
226
- }
227
- guid += 1
228
- tokens = []
229
- pos_tags = []
230
- chunk_tags = []
231
- ner_tags = []
232
- else:
233
- # conll2003 tokens are space separated
234
- splits = line.split(" ")
235
- tokens.append(splits[0])
236
- pos_tags.append(splits[1])
237
- chunk_tags.append(splits[2])
238
- ner_tags.append(splits[3].rstrip())
239
- # last example
240
- if tokens:
241
- yield guid, {
242
- "id": str(guid),
243
- "tokens": tokens,
244
- "pos_tags": pos_tags,
245
- "chunk_tags": chunk_tags,
246
- "ner_tags": ner_tags,
247
- }