phucdev commited on
Commit
e0f61d5
1 Parent(s): 94388c2

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +398 -0
  2. fabner.py +230 -0
README.md ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language:
5
+ - en
6
+ language_creators:
7
+ - found
8
+ license:
9
+ - other
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: FabNER is a manufacturing text dataset for Named Entity Recognition.
13
+ size_categories:
14
+ - 10K<n<100K
15
+ source_datasets: []
16
+ tags:
17
+ - manufacturing
18
+ - 2000-2020
19
+ task_categories:
20
+ - token-classification
21
+ task_ids:
22
+ - named-entity-recognition
23
+ dataset_info:
24
+ - config_name: fabner
25
+ features:
26
+ - name: id
27
+ dtype: string
28
+ - name: tokens
29
+ sequence: string
30
+ - name: ner_tags
31
+ sequence:
32
+ class_label:
33
+ names:
34
+ '0': O
35
+ '1': B-MATE
36
+ '2': I-MATE
37
+ '3': E-MATE
38
+ '4': S-MATE
39
+ '5': B-MANP
40
+ '6': I-MANP
41
+ '7': E-MANP
42
+ '8': S-MANP
43
+ '9': B-MACEQ
44
+ '10': I-MACEQ
45
+ '11': E-MACEQ
46
+ '12': S-MACEQ
47
+ '13': B-APPL
48
+ '14': I-APPL
49
+ '15': E-APPL
50
+ '16': S-APPL
51
+ '17': B-FEAT
52
+ '18': I-FEAT
53
+ '19': E-FEAT
54
+ '20': S-FEAT
55
+ '21': B-PRO
56
+ '22': I-PRO
57
+ '23': E-PRO
58
+ '24': S-PRO
59
+ '25': B-CHAR
60
+ '26': I-CHAR
61
+ '27': E-CHAR
62
+ '28': S-CHAR
63
+ '29': B-PARA
64
+ '30': I-PARA
65
+ '31': E-PARA
66
+ '32': S-PARA
67
+ '33': B-ENAT
68
+ '34': I-ENAT
69
+ '35': E-ENAT
70
+ '36': S-ENAT
71
+ '37': B-CONPRI
72
+ '38': I-CONPRI
73
+ '39': E-CONPRI
74
+ '40': S-CONPRI
75
+ '41': B-MANS
76
+ '42': I-MANS
77
+ '43': E-MANS
78
+ '44': S-MANS
79
+ '45': B-BIOP
80
+ '46': I-BIOP
81
+ '47': E-BIOP
82
+ '48': S-BIOP
83
+ splits:
84
+ - name: train
85
+ num_bytes: 4394010
86
+ num_examples: 9435
87
+ - name: validation
88
+ num_bytes: 934347
89
+ num_examples: 2183
90
+ - name: test
91
+ num_bytes: 940136
92
+ num_examples: 2064
93
+ download_size: 1265830
94
+ dataset_size: 6268493
95
+ - config_name: fabner_bio
96
+ features:
97
+ - name: id
98
+ dtype: string
99
+ - name: tokens
100
+ sequence: string
101
+ - name: ner_tags
102
+ sequence:
103
+ class_label:
104
+ names:
105
+ '0': O
106
+ '1': B-MATE
107
+ '2': I-MATE
108
+ '3': B-MANP
109
+ '4': I-MANP
110
+ '5': B-MACEQ
111
+ '6': I-MACEQ
112
+ '7': B-APPL
113
+ '8': I-APPL
114
+ '9': B-FEAT
115
+ '10': I-FEAT
116
+ '11': B-PRO
117
+ '12': I-PRO
118
+ '13': B-CHAR
119
+ '14': I-CHAR
120
+ '15': B-PARA
121
+ '16': I-PARA
122
+ '17': B-ENAT
123
+ '18': I-ENAT
124
+ '19': B-CONPRI
125
+ '20': I-CONPRI
126
+ '21': B-MANS
127
+ '22': I-MANS
128
+ '23': B-BIOP
129
+ '24': I-BIOP
130
+ splits:
131
+ - name: train
132
+ num_bytes: 4394010
133
+ num_examples: 9435
134
+ - name: validation
135
+ num_bytes: 934347
136
+ num_examples: 2183
137
+ - name: test
138
+ num_bytes: 940136
139
+ num_examples: 2064
140
+ download_size: 1258672
141
+ dataset_size: 6268493
142
+ - config_name: fabner_simple
143
+ features:
144
+ - name: id
145
+ dtype: string
146
+ - name: tokens
147
+ sequence: string
148
+ - name: ner_tags
149
+ sequence:
150
+ class_label:
151
+ names:
152
+ '0': O
153
+ '1': MATE
154
+ '2': MANP
155
+ '3': MACEQ
156
+ '4': APPL
157
+ '5': FEAT
158
+ '6': PRO
159
+ '7': CHAR
160
+ '8': PARA
161
+ '9': ENAT
162
+ '10': CONPRI
163
+ '11': MANS
164
+ '12': BIOP
165
+ splits:
166
+ - name: train
167
+ num_bytes: 4394010
168
+ num_examples: 9435
169
+ - name: validation
170
+ num_bytes: 934347
171
+ num_examples: 2183
172
+ - name: test
173
+ num_bytes: 940136
174
+ num_examples: 2064
175
+ download_size: 1233960
176
+ dataset_size: 6268493
177
+ - config_name: text2tech
178
+ features:
179
+ - name: id
180
+ dtype: string
181
+ - name: tokens
182
+ sequence: string
183
+ - name: ner_tags
184
+ sequence:
185
+ class_label:
186
+ names:
187
+ '0': O
188
+ '1': Technological System
189
+ '2': Method
190
+ '3': Material
191
+ '4': Technical Field
192
+ splits:
193
+ - name: train
194
+ num_bytes: 4394010
195
+ num_examples: 9435
196
+ - name: validation
197
+ num_bytes: 934347
198
+ num_examples: 2183
199
+ - name: test
200
+ num_bytes: 940136
201
+ num_examples: 2064
202
+ download_size: 1192966
203
+ dataset_size: 6268493
204
+ ---
205
+
206
+ # Dataset Card for FabNER
207
+
208
+ ## Table of Contents
209
+ - [Table of Contents](#table-of-contents)
210
+ - [Dataset Description](#dataset-description)
211
+ - [Dataset Summary](#dataset-summary)
212
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
213
+ - [Languages](#languages)
214
+ - [Dataset Structure](#dataset-structure)
215
+ - [Data Instances](#data-instances)
216
+ - [Data Fields](#data-fields)
217
+ - [Data Splits](#data-splits)
218
+ - [Dataset Creation](#dataset-creation)
219
+ - [Curation Rationale](#curation-rationale)
220
+ - [Source Data](#source-data)
221
+ - [Annotations](#annotations)
222
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
223
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
224
+ - [Social Impact of Dataset](#social-impact-of-dataset)
225
+ - [Discussion of Biases](#discussion-of-biases)
226
+ - [Other Known Limitations](#other-known-limitations)
227
+ - [Additional Information](#additional-information)
228
+ - [Dataset Curators](#dataset-curators)
229
+ - [Licensing Information](#licensing-information)
230
+ - [Citation Information](#citation-information)
231
+ - [Contributions](#contributions)
232
+
233
+ ## Dataset Description
234
+
235
+ - **Homepage:** [https://figshare.com/articles/dataset/Dataset_NER_Manufacturing_-_FabNER_Information_Extraction_from_Manufacturing_Process_Science_Domain_Literature_Using_Named_Entity_Recognition/14782407](https://figshare.com/articles/dataset/Dataset_NER_Manufacturing_-_FabNER_Information_Extraction_from_Manufacturing_Process_Science_Domain_Literature_Using_Named_Entity_Recognition/14782407)
236
+ - **Paper:** ["FabNER": information extraction from manufacturing process science domain literature using named entity recognition](https://par.nsf.gov/servlets/purl/10290810)
237
+ - **Size of downloaded dataset files:** 3.79 MB
238
+ - **Size of the generated dataset:** 6.27 MB
239
+
240
+ ### Dataset Summary
241
+
242
+ FabNER is a manufacturing text corpus of 350,000+ words for Named Entity Recognition.
243
+ It is a collection of abstracts obtained from Web of Science through known journals available in manufacturing process
244
+ science research.
245
+ For every word, there were categories/entity labels defined, namely Material (MATE), Manufacturing Process (MANP),
246
+ Machine/Equipment (MACEQ), Application (APPL), Features (FEAT), Mechanical Properties (PRO), Characterization (CHAR),
247
+ Parameters (PARA), Enabling Technology (ENAT), Concept/Principles (CONPRI), Manufacturing Standards (MANS) and
248
+ BioMedical (BIOP). Annotation was performed in all categories along with the output tag in 'BIOES' format:
249
+ B=Beginning, I-Intermediate, O=Outside, E=End, S=Single.
250
+
251
+ For details about the dataset, please refer to the paper: ["FabNER": information extraction from manufacturing process science domain literature using named entity recognition](https://par.nsf.gov/servlets/purl/10290810)
252
+
253
+ ### Supported Tasks and Leaderboards
254
+
255
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
256
+
257
+ ### Languages
258
+
259
+ The language in the dataset is English.
260
+
261
+ ## Dataset Structure
262
+
263
+ ### Data Instances
264
+
265
+ - **Size of downloaded dataset files:** 3.79 MB
266
+ - **Size of the generated dataset:** 6.27 MB
267
+
268
+ An example of 'train' looks as follows:
269
+ ```json
270
+ {
271
+ "id": "0",
272
+ "tokens": ["Revealed", "the", "location-specific", "flow", "patterns", "and", "quantified", "the", "speeds", "of", "various", "types", "of", "flow", "."],
273
+ "ner_tags": [0, 0, 0, 46, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
274
+ }
275
+ ```
276
+
277
+ ### Data Fields
278
+
279
+ #### fabner
280
+ - `id`: the instance id of this sentence, a `string` feature.
281
+ - `tokens`: the list of tokens of this sentence, a `list` of `string` features.
282
+ - `ner_tags`: the list of entity tags, a `list` of classification labels.
283
+
284
+ ```json
285
+ {"O": 0, "B-MATE": 1, "I-MATE": 2, "O-MATE": 3, "E-MATE": 4, "S-MATE": 5, "B-MANP": 6, "I-MANP": 7, "O-MANP": 8, "E-MANP": 9, "S-MANP": 10, "B-MACEQ": 11, "I-MACEQ": 12, "O-MACEQ": 13, "E-MACEQ": 14, "S-MACEQ": 15, "B-APPL": 16, "I-APPL": 17, "O-APPL": 18, "E-APPL": 19, "S-APPL": 20, "B-FEAT": 21, "I-FEAT": 22, "O-FEAT": 23, "E-FEAT": 24, "S-FEAT": 25, "B-PRO": 26, "I-PRO": 27, "O-PRO": 28, "E-PRO": 29, "S-PRO": 30, "B-CHAR": 31, "I-CHAR": 32, "O-CHAR": 33, "E-CHAR": 34, "S-CHAR": 35, "B-PARA": 36, "I-PARA": 37, "O-PARA": 38, "E-PARA": 39, "S-PARA": 40, "B-ENAT": 41, "I-ENAT": 42, "O-ENAT": 43, "E-ENAT": 44, "S-ENAT": 45, "B-CONPRI": 46, "I-CONPRI": 47, "O-CONPRI": 48, "E-CONPRI": 49, "S-CONPRI": 50, "B-MANS": 51, "I-MANS": 52, "O-MANS": 53, "E-MANS": 54, "S-MANS": 55, "B-BIOP": 56, "I-BIOP": 57, "O-BIOP": 58, "E-BIOP": 59, "S-BIOP": 60}
286
+ ```
287
+
288
+ #### fabner_bio
289
+ - `id`: the instance id of this sentence, a `string` feature.
290
+ - `tokens`: the list of tokens of this sentence, a `list` of `string` features.
291
+ - `ner_tags`: the list of entity tags, a `list` of classification labels.
292
+
293
+ ```json
294
+ {"O": 0, "B-MATE": 1, "I-MATE": 2, "B-MANP": 3, "I-MANP": 4, "B-MACEQ": 5, "I-MACEQ": 6, "B-APPL": 7, "I-APPL": 8, "B-FEAT": 9, "I-FEAT": 10, "B-PRO": 11, "I-PRO": 12, "B-CHAR": 13, "I-CHAR": 14, "B-PARA": 15, "I-PARA": 16, "B-ENAT": 17, "I-ENAT": 18, "B-CONPRI": 19, "I-CONPRI": 20, "B-MANS": 21, "I-MANS": 22, "B-BIOP": 23, "I-BIOP": 24}
295
+ ```
296
+
297
+ #### fabner_simple
298
+ - `id`: the instance id of this sentence, a `string` feature.
299
+ - `tokens`: the list of tokens of this sentence, a `list` of `string` features.
300
+ - `ner_tags`: the list of entity tags, a `list` of classification labels.
301
+
302
+ ```json
303
+ {"O": 0, "MATE": 1, "MANP": 2, "MACEQ": 3, "APPL": 4, "FEAT": 5, "PRO": 6, "CHAR": 7, "PARA": 8, "ENAT": 9, "CONPRI": 10, "MANS": 11, "BIOP": 12}
304
+ ```
305
+
306
+ #### text2tech
307
+ - `id`: the instance id of this sentence, a `string` feature.
308
+ - `tokens`: the list of tokens of this sentence, a `list` of `string` features.
309
+ - `ner_tags`: the list of entity tags, a `list` of classification labels.
310
+
311
+ ```json
312
+ {"O": 0, "Technological System": 1, "Method": 2, "Material": 3, "Technical Field": 4}
313
+ ```
314
+
315
+ ### Data Splits
316
+
317
+ | | Train | Dev | Test |
318
+ |--------|-------|------|------|
319
+ | fabner | 9435 | 2183 | 2064 |
320
+
321
+ ## Dataset Creation
322
+
323
+ ### Curation Rationale
324
+
325
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
326
+
327
+ ### Source Data
328
+
329
+ #### Initial Data Collection and Normalization
330
+
331
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
332
+
333
+ #### Who are the source language producers?
334
+
335
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
336
+
337
+ ### Annotations
338
+
339
+ #### Annotation process
340
+
341
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
342
+
343
+ #### Who are the annotators?
344
+
345
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
346
+
347
+ ### Personal and Sensitive Information
348
+
349
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
350
+
351
+ ## Considerations for Using the Data
352
+
353
+ ### Social Impact of Dataset
354
+
355
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
356
+
357
+ ### Discussion of Biases
358
+
359
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
360
+
361
+ ### Other Known Limitations
362
+
363
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
364
+
365
+ ## Additional Information
366
+
367
+ ### Dataset Curators
368
+
369
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
370
+
371
+ ### Licensing Information
372
+
373
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
374
+
375
+ ### Citation Information
376
+
377
+ ```
378
+ @article{DBLP:journals/jim/KumarS22,
379
+ author = {Aman Kumar and
380
+ Binil Starly},
381
+ title = {"FabNER": information extraction from manufacturing process science
382
+ domain literature using named entity recognition},
383
+ journal = {J. Intell. Manuf.},
384
+ volume = {33},
385
+ number = {8},
386
+ pages = {2393--2407},
387
+ year = {2022},
388
+ url = {https://doi.org/10.1007/s10845-021-01807-x},
389
+ doi = {10.1007/s10845-021-01807-x},
390
+ timestamp = {Sun, 13 Nov 2022 17:52:57 +0100},
391
+ biburl = {https://dblp.org/rec/journals/jim/KumarS22.bib},
392
+ bibsource = {dblp computer science bibliography, https://dblp.org}
393
+ }
394
+ ```
395
+
396
+ ### Contributions
397
+
398
+ Thanks to [@phucdev](https://github.com/phucdev) for adding this dataset.
fabner.py ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """FabNER is a manufacturing text corpus of 350,000+ words for Named Entity Recognition."""
15
+
16
+ import datasets
17
+
18
+
19
+ # Find for instance the citation on arxiv or on the dataset repo/website
20
+ _CITATION = """\
21
+ @article{DBLP:journals/jim/KumarS22,
22
+ author = {Aman Kumar and
23
+ Binil Starly},
24
+ title = {"FabNER": information extraction from manufacturing process science
25
+ domain literature using named entity recognition},
26
+ journal = {J. Intell. Manuf.},
27
+ volume = {33},
28
+ number = {8},
29
+ pages = {2393--2407},
30
+ year = {2022},
31
+ url = {https://doi.org/10.1007/s10845-021-01807-x},
32
+ doi = {10.1007/s10845-021-01807-x},
33
+ timestamp = {Sun, 13 Nov 2022 17:52:57 +0100},
34
+ biburl = {https://dblp.org/rec/journals/jim/KumarS22.bib},
35
+ bibsource = {dblp computer science bibliography, https://dblp.org}
36
+ }
37
+ """
38
+
39
+ # You can copy an official description
40
+ _DESCRIPTION = """\
41
+ FabNER is a manufacturing text corpus of 350,000+ words for Named Entity Recognition.
42
+ It is a collection of abstracts obtained from Web of Science through known journals available in manufacturing process
43
+ science research.
44
+ For every word, there were categories/entity labels defined namely Material (MATE), Manufacturing Process (MANP),
45
+ Machine/Equipment (MACEQ), Application (APPL), Features (FEAT), Mechanical Properties (PRO), Characterization (CHAR),
46
+ Parameters (PARA), Enabling Technology (ENAT), Concept/Principles (CONPRI), Manufacturing Standards (MANS) and
47
+ BioMedical (BIOP). Annotation was performed in all categories along with the output tag in 'BIOES' format:
48
+ B=Beginning, I-Intermediate, O=Outside, E=End, S=Single.
49
+ """
50
+
51
+ _HOMEPAGE = "https://figshare.com/articles/dataset/Dataset_NER_Manufacturing_-_FabNER_Information_Extraction_from_Manufacturing_Process_Science_Domain_Literature_Using_Named_Entity_Recognition/14782407"
52
+
53
+ # TODO: Add the licence for the dataset here if you can find it
54
+ _LICENSE = ""
55
+
56
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
57
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
58
+ _URLS = {
59
+ "train": "https://figshare.com/ndownloader/files/28405854/S2-train.txt",
60
+ "validation": "https://figshare.com/ndownloader/files/28405857/S3-val.txt",
61
+ "test": "https://figshare.com/ndownloader/files/28405851/S1-test.txt",
62
+ }
63
+
64
+
65
+ def map_fabner_labels(string_tag):
66
+ tag = string_tag[2:]
67
+ # MATERIAL (FABNER)
68
+ if tag == "MATE":
69
+ return "Material"
70
+ # MANUFACTURING PROCESS (FABNER)
71
+ elif tag == "MANP":
72
+ return "Method"
73
+ # MACHINE/EQUIPMENT, MECHANICAL PROPERTIES, CHARACTERIZATION, ENABLING TECHNOLOGY (FABNER)
74
+ elif tag in ["MACEQ", "PRO", "CHAR", "ENAT"]:
75
+ return "Technological System"
76
+ # APPLICATION (FABNER)
77
+ elif tag == "APPL":
78
+ return "Technical Field"
79
+ # FEATURES, PARAMETERS, CONCEPT/PRINCIPLES, MANUFACTURING STANDARDS, BIOMEDICAL, O (FABNER)
80
+ else:
81
+ return "O"
82
+
83
+
84
+ class FabNER(datasets.GeneratorBasedBuilder):
85
+ """FabNER is a manufacturing text corpus of 350,000+ words for Named Entity Recognition."""
86
+
87
+ VERSION = datasets.Version("1.2.0")
88
+
89
+ # This is an example of a dataset with multiple configurations.
90
+ # If you don't want/need to define several sub-sets in your dataset,
91
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
92
+
93
+ # If you need to make complex sub-parts in the datasets with configurable options
94
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
95
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
96
+
97
+ # You will be able to load one or the other configurations in the following list with
98
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
99
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
100
+ BUILDER_CONFIGS = [
101
+ datasets.BuilderConfig(name="fabner", version=VERSION,
102
+ description="The FabNER dataset with the original BIOES tagging format"),
103
+ datasets.BuilderConfig(name="fabner_bio", version=VERSION,
104
+ description="The FabNER dataset with BIO tagging format"),
105
+ datasets.BuilderConfig(name="fabner_simple", version=VERSION,
106
+ description="The FabNER dataset with no tagging format"),
107
+ datasets.BuilderConfig(name="text2tech", version=VERSION,
108
+ description="The FabNER dataset mapped to the Text2Tech tag set"),
109
+ ]
110
+ DEFAULT_CONFIG_NAME = "fabner"
111
+
112
+ def _info(self):
113
+ entity_types = [
114
+ "MATE", # Material
115
+ "MANP", # Manufacturing Process
116
+ "MACEQ", # Machine/Equipment
117
+ "APPL", # Application
118
+ "FEAT", # Engineering Features
119
+ "PRO", # Mechanical Properties
120
+ "CHAR", # Process Characterization
121
+ "PARA", # Process Parameters
122
+ "ENAT", # Enabling Technology
123
+ "CONPRI", # Concept/Principles
124
+ "MANS", # Manufacturing Standards
125
+ "BIOP", # BioMedical
126
+ ]
127
+ if self.config.name == "text2tech":
128
+ class_labels = ["O", "Technological System", "Method", "Material", "Technical Field"]
129
+ elif self.config.name == "fabner":
130
+ class_labels = ["O"]
131
+ for entity_type in entity_types:
132
+ class_labels.extend(
133
+ [
134
+ "B-" + entity_type,
135
+ "I-" + entity_type,
136
+ "E-" + entity_type,
137
+ "S-" + entity_type,
138
+ ]
139
+ )
140
+ elif self.config.name == "fabner_bio":
141
+ class_labels = ["O"]
142
+ for entity_type in entity_types:
143
+ class_labels.extend(
144
+ [
145
+ "B-" + entity_type,
146
+ "I-" + entity_type,
147
+ ]
148
+ )
149
+ else:
150
+ class_labels = ["O"] + entity_types
151
+ features = datasets.Features(
152
+ {
153
+ "id": datasets.Value("string"),
154
+ "tokens": datasets.Sequence(datasets.Value("string")),
155
+ "ner_tags": datasets.Sequence(
156
+ datasets.features.ClassLabel(
157
+ names=class_labels
158
+ )
159
+ ),
160
+ }
161
+ )
162
+ return datasets.DatasetInfo(
163
+ # This is the description that will appear on the datasets page.
164
+ description=_DESCRIPTION,
165
+ # This defines the different columns of the dataset and their types
166
+ features=features, # Here we define them above because they are different between the two configurations
167
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
168
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
169
+ # supervised_keys=("sentence", "label"),
170
+ # Homepage of the dataset for documentation
171
+ homepage=_HOMEPAGE,
172
+ # License for the dataset if available
173
+ license=_LICENSE,
174
+ # Citation for the dataset
175
+ citation=_CITATION,
176
+ )
177
+
178
+ def _split_generators(self, dl_manager):
179
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
180
+
181
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
182
+ # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
183
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
184
+ downloaded_files = dl_manager.download_and_extract(_URLS)
185
+
186
+ return [datasets.SplitGenerator(name=i, gen_kwargs={"filepath": downloaded_files[str(i)]})
187
+ for i in [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]]
188
+
189
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
190
+ def _generate_examples(self, filepath):
191
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
192
+ with open(filepath, encoding="utf-8") as f:
193
+ guid = 0
194
+ tokens = []
195
+ ner_tags = []
196
+ for line in f:
197
+ if line == "" or line == "\n":
198
+ if tokens:
199
+ yield guid, {
200
+ "id": str(guid),
201
+ "tokens": tokens,
202
+ "ner_tags": ner_tags,
203
+ }
204
+ guid += 1
205
+ tokens = []
206
+ ner_tags = []
207
+ else:
208
+ splits = line.split(" ")
209
+ tokens.append(splits[0])
210
+ ner_tag = splits[1].rstrip()
211
+ if self.config.name == "fabner_simple":
212
+ if ner_tag == "O":
213
+ ner_tag = "O"
214
+ else:
215
+ ner_tag = ner_tag.split("-")[1]
216
+ elif self.config.name == "fabner_bio":
217
+ if ner_tag == "O":
218
+ ner_tag = "O"
219
+ else:
220
+ ner_tag = ner_tag.replace("S-", "B-").replace("E-", "I-")
221
+ elif self.config.name == "text2tech":
222
+ ner_tag = map_fabner_labels(ner_tag)
223
+ ner_tags.append(ner_tag)
224
+ # last example
225
+ if tokens:
226
+ yield guid, {
227
+ "id": str(guid),
228
+ "tokens": tokens,
229
+ "ner_tags": ner_tags,
230
+ }