system HF staff commited on
Commit
ad98ea1
0 Parent(s):

Update files from the datasets library (from 1.2.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.2.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - cc-by-4-0
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ - n<1K
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - sequence-modeling
18
+ - structure-prediction
19
+ - text-classification
20
+ task_ids:
21
+ - named-entity-recognition
22
+ - slot-filling
23
+ - topic-classification
24
+ ---
25
+
26
+
27
+ # Dataset Card Creation Guide
28
+
29
+ ## Table of Contents
30
+ - [Dataset Description](#dataset-description)
31
+ - [Dataset Summary](#dataset-summary)
32
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
33
+ - [Languages](#languages)
34
+ - [Dataset Structure](#dataset-structure)
35
+ - [Data Instances](#data-instances)
36
+ - [Data Fields](#data-fields)
37
+ - [Data Splits](#data-splits)
38
+ - [Dataset Creation](#dataset-creation)
39
+ - [Curation Rationale](#curation-rationale)
40
+ - [Source Data](#source-data)
41
+ - [Annotations](#annotations)
42
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
43
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
44
+ - [Social Impact of Dataset](#social-impact-of-dataset)
45
+ - [Discussion of Biases](#discussion-of-biases)
46
+ - [Other Known Limitations](#other-known-limitations)
47
+ - [Additional Information](#additional-information)
48
+ - [Dataset Curators](#dataset-curators)
49
+ - [Licensing Information](#licensing-information)
50
+ - [Citation Information](#citation-information)
51
+
52
+ ## Dataset Description
53
+
54
+ - **Homepage:** [boschresearch/sofc-exp_textmining_resources](https://github.com/boschresearch/sofc-exp_textmining_resources)
55
+ - **Repository:** [boschresearch/sofc-exp_textmining_resources](https://github.com/boschresearch/sofc-exp_textmining_resources)
56
+ - **Paper:** [The SOFC-Exp Corpus and Neural Approaches to Information Extraction in the Materials Science Domain](https://arxiv.org/abs/2006.03039)
57
+ - **Leaderboard:**
58
+ - **Point of Contact:** [Annemarie Friedrich]([email protected])
59
+
60
+ ### Dataset Summary
61
+
62
+ > The SOFC-Exp corpus contains 45 scientific publications about solid oxide fuel cells (SOFCs), published between 2013 and 2019 as open-access articles all with a CC-BY license. The dataset was manually annotated by domain experts with the following information:
63
+ >
64
+ > * Mentions of relevant experiments have been marked using a graph structure corresponding to instances of an Experiment frame (similar to the ones used in FrameNet.) We assume that an Experiment frame is introduced to the discourse by mentions of words such as report, test or measure (also called the frame-evoking elements). The nodes corresponding to the respective tokens are the heads of the graphs representing the Experiment frame.
65
+ > * The Experiment frame related to SOFC-Experiments defines a set of 16 possible participant slots. Participants are annotated as dependents of links between the frame-evoking element and the participant node.
66
+ > * In addition, we provide coarse-grained entity/concept types for all frame participants, i.e, MATERIAL, VALUE or DEVICE. Note that this annotation has not been performed on the full texts but only on sentences containing information about relevant experiments, and a few sentences in addition. In the paper, we run experiments for both tasks only on the set of sentences marked as experiment-describing in the gold standard, which is admittedly a slightly simplified setting. Entity types are only partially annotated on other sentences. Slot filling could of course also be evaluated in a fully automatic setting with automatic experiment sentence detection as a first step.
67
+
68
+ ### Supported Tasks and Leaderboards
69
+
70
+ - `topic-classification`: The dataset can be used to train a model for topic-classification, to identify sentences that mention SOFC-related experiments.
71
+ - `named-entity-recognition`: The dataset can be used to train a named entity recognition model to detect `MATERIAL`, `VALUE`, `DEVICE`, and `EXPERIMENT` entities.
72
+ - `slot-filling`: The slot-filling task is approached as fine-grained entity-typing-in-context, assuming that each sentence represents a single experiment frame. Sequence tagging architectures are utilized for tagging the tokens of each experiment-describing sentence with the set of slot types.
73
+
74
+
75
+ The paper experiments with BiLSTM architectures with `BERT`- and `SciBERT`- generated token embeddings, as well as with `BERT` and `SciBERT` directly for the modeling task. A simple CRF architecture is used as a baseline for sequence-tagging tasks. Implementations of the transformer-based architectures can be found in the `huggingface/transformers` library: [BERT](https://huggingface.co/bert-base-uncased), [SciBERT](https://huggingface.co/allenai/scibert_scivocab_uncased)
76
+
77
+ ### Languages
78
+
79
+ This corpus is in English.
80
+
81
+ ## Dataset Structure
82
+
83
+ ### Data Instances
84
+
85
+ As each example is a full text of an academic paper, plus annotations, a json formatted example is space-prohibitive for this README.
86
+
87
+ ### Data Fields
88
+
89
+ - `text`: The full text of the paper
90
+ - `sentence_offsets`: Start and end character offsets for each sentence in the text.
91
+ - `begin_char_offset`: a `int64` feature.
92
+ - `end_char_offset`: a `int64` feature.
93
+ - `sentences`: A sequence of the sentences in the text (using `sentence_offsets`)
94
+ - `sentence_labels`: Sequence of binary labels for whether a sentence contains information of interest.
95
+ - `token_offsets`: Sequence of sequences containing start and end character offsets for each token in each sentence in the text.
96
+ - `offsets`: a dictionary feature containing:
97
+ - `begin_char_offset`: a `int64` feature.
98
+ - `end_char_offset`: a `int64` feature.
99
+ - `tokens`: Sequence of sequences containing the tokens for each sentence in the text.
100
+ - `feature`: a `string` feature.
101
+ - `entity_labels`: a dictionary feature containing:
102
+ - `feature`: a classification label, with possible values including `B-DEVICE`, `B-EXPERIMENT`, `B-MATERIAL`, `B-VALUE`, `I-DEVICE`.
103
+ - `slot_labels`: a dictionary feature containing:
104
+ - `feature`: a classification label, with possible values including `B-anode_material`, `B-cathode_material`, `B-conductivity`, `B-current_density`, `B-degradation_rate`.
105
+ - `links`: a dictionary feature containing:
106
+ - `relation_label`: a classification label, with possible values including `coreference`, `experiment_variation`, `same_experiment`, `thickness`.
107
+ - `start_span_id`: a `int64` feature.
108
+ - `end_span_id`: a `int64` feature.
109
+ - `slots`: a dictionary feature containing:
110
+ - `frame_participant_label`: a classification label, with possible values including `anode_material`, `cathode_material`, `current_density`, `degradation_rate`, `device`.
111
+ - `slot_id`: a `int64` feature.
112
+ - `spans`: a dictionary feature containing:
113
+ - `span_id`: a `int64` feature.
114
+ - `entity_label`: a classification label, with possible values including ``, `DEVICE`, `MATERIAL`, `VALUE`.
115
+ - `sentence_id`: a `int64` feature.
116
+ - `experiment_mention_type`: a classification label, with possible values including ``, `current_exp`, `future_work`, `general_info`, `previous_work`.
117
+ - `begin_char_offset`: a `int64` feature.
118
+ - `end_char_offset`: a `int64` feature.
119
+ - `experiments`: a dictionary feature containing:
120
+ - `experiment_id`: a `int64` feature.
121
+ - `span_id`: a `int64` feature.
122
+ - `slots`: a dictionary feature containing:
123
+ - `frame_participant_label`: a classification label, with possible values including `anode_material`, `cathode_material`, `current_density`, `degradation_rate`, `conductivity`.
124
+ - `slot_id`: a `int64` feature.
125
+
126
+ Very detailed information for each of the fields can be found in the [corpus file formats section](https://github.com/boschresearch/sofc-exp_textmining_resources#corpus-file-formats) of the associated dataset repo
127
+
128
+ ### Data Splits
129
+
130
+ This dataset consists of three splits:
131
+
132
+ | | Train | Valid | Test |
133
+ | ----- | ------ | ----- | ---- |
134
+ | Input Examples | 26 | 8 | 11 |
135
+
136
+
137
+ The authors propose the experimental setting of using the training data in a 5-fold cross validation setting for development and tuning, and finally applying tte model(s) to the independent test set.
138
+
139
+ ## Dataset Creation
140
+
141
+ ### Curation Rationale
142
+
143
+ [More Information Needed]
144
+
145
+ ### Source Data
146
+
147
+ #### Initial Data Collection and Normalization
148
+
149
+ [More Information Needed]
150
+
151
+ #### Who are the source language producers?
152
+
153
+ The corpus consists of 45
154
+ open-access scientific publications about SOFCs
155
+ and related research, annotated by domain experts.
156
+
157
+ ### Annotations
158
+
159
+ #### Annotation process
160
+
161
+ For manual annotation, the authors use the InCeption annotation tool (Klie et al., 2018).
162
+
163
+ #### Who are the annotators?
164
+
165
+ [More Information Needed]
166
+
167
+ ### Personal and Sensitive Information
168
+
169
+ [More Information Needed]
170
+ ## Considerations for Using the Data
171
+
172
+ ### Social Impact of Dataset
173
+
174
+ [More Information Needed]
175
+
176
+ ### Discussion of Biases
177
+
178
+ [More Information Needed]
179
+
180
+ ### Other Known Limitations
181
+
182
+ [More Information Needed]
183
+
184
+ ## Additional Information
185
+
186
+ ### Dataset Curators
187
+
188
+ [More Information Needed]
189
+
190
+ ### Licensing Information
191
+
192
+ The manual annotations created for the SOFC-Exp corpus are licensed under a [Creative Commons Attribution 4.0 International License (CC-BY-4.0)](https://creativecommons.org/licenses/by/4.0/).
193
+
194
+ ### Citation Information
195
+
196
+ ```
197
+ @misc{friedrich2020sofcexp,
198
+ title={The SOFC-Exp Corpus and Neural Approaches to Information Extraction in the Materials Science Domain},
199
+ author={Annemarie Friedrich and Heike Adel and Federico Tomazic and Johannes Hingerl and Renou Benteau and Anika Maruscyk and Lukas Lange},
200
+ year={2020},
201
+ eprint={2006.03039},
202
+ archivePrefix={arXiv},
203
+ primaryClass={cs.CL}
204
+ }
205
+ ```
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"default": {"description": "The SOFC-Exp corpus consists of 45 open-access scholarly articles annotated by domain experts.\nA corpus and an inter-annotator agreement study demonstrate the complexity of the suggested\nnamed entity recognition and slot filling tasks as well as high annotation quality is presented\nin the accompanying paper.\n", "citation": "@misc{friedrich2020sofcexp,\n title={The SOFC-Exp Corpus and Neural Approaches to Information Extraction in the Materials Science Domain},\n author={Annemarie Friedrich and Heike Adel and Federico Tomazic and Johannes Hingerl and Renou Benteau and Anika Maruscyk and Lukas Lange},\n year={2020},\n eprint={2006.03039},\n archivePrefix={arXiv},\n primaryClass={cs.CL}\n}\n", "homepage": "https://arxiv.org/abs/2006.03039", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "sentence_offsets": {"feature": {"begin_char_offset": {"dtype": "int64", "id": null, "_type": "Value"}, "end_char_offset": {"dtype": "int64", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "sentences": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "sentence_labels": {"feature": {"dtype": "int64", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "token_offsets": {"feature": {"offsets": {"feature": {"begin_char_offset": {"dtype": "int64", "id": null, "_type": "Value"}, "end_char_offset": {"dtype": "int64", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}, "tokens": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "entity_labels": {"feature": {"feature": {"num_classes": 9, "names": ["B-DEVICE", "B-EXPERIMENT", "B-MATERIAL", "B-VALUE", "I-DEVICE", "I-EXPERIMENT", "I-MATERIAL", "I-VALUE", "O"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "slot_labels": {"feature": {"feature": {"num_classes": 39, "names": ["B-anode_material", "B-cathode_material", "B-conductivity", "B-current_density", "B-degradation_rate", "B-device", "B-electrolyte_material", "B-experiment_evoking_word", "B-fuel_used", "B-interlayer_material", "B-interconnect_material", "B-open_circuit_voltage", "B-power_density", "B-resistance", "B-support_material", "B-thickness", "B-time_of_operation", "B-voltage", "B-working_temperature", "I-anode_material", "I-cathode_material", "I-conductivity", "I-current_density", "I-degradation_rate", "I-device", "I-electrolyte_material", "I-experiment_evoking_word", "I-fuel_used", "I-interlayer_material", "I-interconnect_material", "I-open_circuit_voltage", "I-power_density", "I-resistance", "I-support_material", "I-thickness", "I-time_of_operation", "I-voltage", "I-working_temperature", "O"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "links": {"feature": {"relation_label": {"num_classes": 4, "names": ["coreference", "experiment_variation", "same_experiment", "thickness"], "names_file": null, "id": null, "_type": "ClassLabel"}, "start_span_id": {"dtype": "int64", "id": null, "_type": "Value"}, "end_span_id": {"dtype": "int64", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "slots": {"feature": {"frame_participant_label": {"num_classes": 15, "names": ["anode_material", "cathode_material", "current_density", "degradation_rate", "device", "electrolyte_material", "fuel_used", "interlayer_material", "open_circuit_voltage", "power_density", "resistance", "support_material", "time_of_operation", "voltage", "working_temperature"], "names_file": null, "id": null, "_type": "ClassLabel"}, "slot_id": {"dtype": "int64", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "spans": {"feature": {"span_id": {"dtype": "int64", "id": null, "_type": "Value"}, "entity_label": {"num_classes": 4, "names": ["", "DEVICE", "MATERIAL", "VALUE"], "names_file": null, "id": null, "_type": "ClassLabel"}, "sentence_id": {"dtype": "int64", "id": null, "_type": "Value"}, "experiment_mention_type": {"num_classes": 5, "names": ["", "current_exp", "future_work", "general_info", "previous_work"], "names_file": null, "id": null, "_type": "ClassLabel"}, "begin_char_offset": {"dtype": "int64", "id": null, "_type": "Value"}, "end_char_offset": {"dtype": "int64", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "experiments": {"feature": {"experiment_id": {"dtype": "int64", "id": null, "_type": "Value"}, "span_id": {"dtype": "int64", "id": null, "_type": "Value"}, "slots": {"feature": {"frame_participant_label": {"num_classes": 16, "names": ["anode_material", "cathode_material", "current_density", "degradation_rate", "conductivity", "device", "electrolyte_material", "fuel_used", "interlayer_material", "open_circuit_voltage", "power_density", "resistance", "support_material", "time_of_operation", "voltage", "working_temperature"], "names_file": null, "id": null, "_type": "ClassLabel"}, "slot_id": {"dtype": "int64", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "sofc_materials_articles", "config_name": "default", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 7402373, "num_examples": 26, "dataset_name": "sofc_materials_articles"}, "test": {"name": "test", "num_bytes": 2650700, "num_examples": 11, "dataset_name": "sofc_materials_articles"}, "validation": {"name": "validation", "num_bytes": 1993857, "num_examples": 8, "dataset_name": "sofc_materials_articles"}}, "download_checksums": {"https://github.com/boschresearch/sofc-exp_textmining_resources/archive/master.zip": {"num_bytes": 3733137, "checksum": "8f55da5c16b4e91e484b4f6e4eee89f3b2773fa586a649c639eb1c66e3323deb"}}, "download_size": 3733137, "post_processing_size": null, "dataset_size": 12046930, "size_in_bytes": 15780067}}
dummy/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1eba93cb2be57db7576b730571d277b9d8ddef29d7109680b6f3199ad9fc3f79
3
+ size 20887
sofc_materials_articles.py ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ """TODO: Add a description here."""
16
+
17
+ from __future__ import absolute_import, division, print_function
18
+
19
+ import glob
20
+ import os
21
+
22
+ import pandas as pd
23
+
24
+ import datasets
25
+
26
+
27
+ _CITATION = """\
28
+ @misc{friedrich2020sofcexp,
29
+ title={The SOFC-Exp Corpus and Neural Approaches to Information Extraction in the Materials Science Domain},
30
+ author={Annemarie Friedrich and Heike Adel and Federico Tomazic and Johannes Hingerl and Renou Benteau and Anika Maruscyk and Lukas Lange},
31
+ year={2020},
32
+ eprint={2006.03039},
33
+ archivePrefix={arXiv},
34
+ primaryClass={cs.CL}
35
+ }
36
+ """
37
+
38
+ _DESCRIPTION = """\
39
+ The SOFC-Exp corpus consists of 45 open-access scholarly articles annotated by domain experts.
40
+ A corpus and an inter-annotator agreement study demonstrate the complexity of the suggested
41
+ named entity recognition and slot filling tasks as well as high annotation quality is presented
42
+ in the accompanying paper.
43
+ """
44
+
45
+ _HOMEPAGE = "https://arxiv.org/abs/2006.03039"
46
+
47
+ _LICENSE = ""
48
+
49
+ _URL = "https://github.com/boschresearch/sofc-exp_textmining_resources/archive/master.zip"
50
+
51
+
52
+ class SOFCMaterialsArticles(datasets.GeneratorBasedBuilder):
53
+ """"""
54
+
55
+ VERSION = datasets.Version("1.1.0")
56
+
57
+ def _info(self):
58
+ features = datasets.Features(
59
+ {
60
+ "text": datasets.Value("string"),
61
+ "sentence_offsets": datasets.features.Sequence(
62
+ {"begin_char_offset": datasets.Value("int64"), "end_char_offset": datasets.Value("int64")}
63
+ ),
64
+ "sentences": datasets.features.Sequence(datasets.Value("string")),
65
+ "sentence_labels": datasets.features.Sequence(datasets.Value("int64")),
66
+ "token_offsets": datasets.features.Sequence(
67
+ {
68
+ "offsets": datasets.features.Sequence(
69
+ {"begin_char_offset": datasets.Value("int64"), "end_char_offset": datasets.Value("int64")}
70
+ )
71
+ }
72
+ ),
73
+ "tokens": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))),
74
+ "entity_labels": datasets.features.Sequence(
75
+ datasets.features.Sequence(
76
+ datasets.features.ClassLabel(
77
+ names=[
78
+ "B-DEVICE",
79
+ "B-EXPERIMENT",
80
+ "B-MATERIAL",
81
+ "B-VALUE",
82
+ "I-DEVICE",
83
+ "I-EXPERIMENT",
84
+ "I-MATERIAL",
85
+ "I-VALUE",
86
+ "O",
87
+ ]
88
+ )
89
+ )
90
+ ),
91
+ "slot_labels": datasets.features.Sequence(
92
+ datasets.features.Sequence(
93
+ datasets.features.ClassLabel(
94
+ names=[
95
+ "B-anode_material",
96
+ "B-cathode_material",
97
+ "B-conductivity",
98
+ "B-current_density",
99
+ "B-degradation_rate",
100
+ "B-device",
101
+ "B-electrolyte_material",
102
+ "B-experiment_evoking_word",
103
+ "B-fuel_used",
104
+ "B-interlayer_material",
105
+ "B-interconnect_material",
106
+ "B-open_circuit_voltage",
107
+ "B-power_density",
108
+ "B-resistance",
109
+ "B-support_material",
110
+ "B-thickness",
111
+ "B-time_of_operation",
112
+ "B-voltage",
113
+ "B-working_temperature",
114
+ "I-anode_material",
115
+ "I-cathode_material",
116
+ "I-conductivity",
117
+ "I-current_density",
118
+ "I-degradation_rate",
119
+ "I-device",
120
+ "I-electrolyte_material",
121
+ "I-experiment_evoking_word",
122
+ "I-fuel_used",
123
+ "I-interlayer_material",
124
+ "I-interconnect_material",
125
+ "I-open_circuit_voltage",
126
+ "I-power_density",
127
+ "I-resistance",
128
+ "I-support_material",
129
+ "I-thickness",
130
+ "I-time_of_operation",
131
+ "I-voltage",
132
+ "I-working_temperature",
133
+ "O",
134
+ ]
135
+ )
136
+ )
137
+ ),
138
+ "links": datasets.Sequence(
139
+ {
140
+ "relation_label": datasets.features.ClassLabel(
141
+ names=["coreference", "experiment_variation", "same_experiment", "thickness"]
142
+ ),
143
+ "start_span_id": datasets.Value("int64"),
144
+ "end_span_id": datasets.Value("int64"),
145
+ }
146
+ ),
147
+ "slots": datasets.features.Sequence(
148
+ {
149
+ "frame_participant_label": datasets.features.ClassLabel(
150
+ names=[
151
+ "anode_material",
152
+ "cathode_material",
153
+ "current_density",
154
+ "degradation_rate",
155
+ "device",
156
+ "electrolyte_material",
157
+ "fuel_used",
158
+ "interlayer_material",
159
+ "open_circuit_voltage",
160
+ "power_density",
161
+ "resistance",
162
+ "support_material",
163
+ "time_of_operation",
164
+ "voltage",
165
+ "working_temperature",
166
+ ]
167
+ ),
168
+ "slot_id": datasets.Value("int64"),
169
+ }
170
+ ),
171
+ "spans": datasets.features.Sequence(
172
+ {
173
+ "span_id": datasets.Value("int64"),
174
+ "entity_label": datasets.features.ClassLabel(names=["", "DEVICE", "MATERIAL", "VALUE"]),
175
+ "sentence_id": datasets.Value("int64"),
176
+ "experiment_mention_type": datasets.features.ClassLabel(
177
+ names=["", "current_exp", "future_work", "general_info", "previous_work"]
178
+ ),
179
+ "begin_char_offset": datasets.Value("int64"),
180
+ "end_char_offset": datasets.Value("int64"),
181
+ }
182
+ ),
183
+ "experiments": datasets.features.Sequence(
184
+ {
185
+ "experiment_id": datasets.Value("int64"),
186
+ "span_id": datasets.Value("int64"),
187
+ "slots": datasets.features.Sequence(
188
+ {
189
+ "frame_participant_label": datasets.features.ClassLabel(
190
+ names=[
191
+ "anode_material",
192
+ "cathode_material",
193
+ "current_density",
194
+ "degradation_rate",
195
+ "conductivity",
196
+ "device",
197
+ "electrolyte_material",
198
+ "fuel_used",
199
+ "interlayer_material",
200
+ "open_circuit_voltage",
201
+ "power_density",
202
+ "resistance",
203
+ "support_material",
204
+ "time_of_operation",
205
+ "voltage",
206
+ "working_temperature",
207
+ ]
208
+ ),
209
+ "slot_id": datasets.Value("int64"),
210
+ }
211
+ ),
212
+ }
213
+ ),
214
+ }
215
+ )
216
+
217
+ return datasets.DatasetInfo(
218
+ # This is the description that will appear on the datasets page.
219
+ description=_DESCRIPTION,
220
+ # This defines the different columns of the dataset and their types
221
+ features=features, # Here we define them above because they are different between the two configurations
222
+ # If there's a common (input, target) tuple from the features,
223
+ # specify them here. They'll be used if as_supervised=True in
224
+ # builder.as_dataset.
225
+ supervised_keys=None,
226
+ # Homepage of the dataset for documentation
227
+ homepage=_HOMEPAGE,
228
+ # License for the dataset if available
229
+ license=_LICENSE,
230
+ # Citation for the dataset
231
+ citation=_CITATION,
232
+ )
233
+
234
+ def _split_generators(self, dl_manager):
235
+ """Returns SplitGenerators."""
236
+
237
+ my_urls = _URL
238
+ data_dir = dl_manager.download_and_extract(my_urls)
239
+
240
+ data_dir = os.path.join(data_dir, "sofc-exp_textmining_resources-master/sofc-exp-corpus")
241
+
242
+ metadata = pd.read_csv(os.path.join(data_dir, "SOFC-Exp-Metadata.csv"), sep="\t")
243
+
244
+ text_base_path = os.path.join(data_dir, "texts")
245
+
246
+ text_files_available = [
247
+ os.path.split(i.rstrip(".txt"))[-1] for i in glob.glob(os.path.join(text_base_path, "*.txt"))
248
+ ]
249
+
250
+ metadata = metadata[metadata["name"].map(lambda x: x in text_files_available)]
251
+
252
+ names = {}
253
+ splits = ["train", "test", "dev"]
254
+ for split in splits:
255
+ names[split] = metadata[metadata["set"] == split]["name"].tolist()
256
+
257
+ return [
258
+ datasets.SplitGenerator(
259
+ name=datasets.Split.TRAIN,
260
+ # These kwargs will be passed to _generate_examples
261
+ gen_kwargs={
262
+ "names": names["train"],
263
+ "data_dir": data_dir,
264
+ "split": "train",
265
+ },
266
+ ),
267
+ datasets.SplitGenerator(
268
+ name=datasets.Split.TEST,
269
+ # These kwargs will be passed to _generate_examples
270
+ gen_kwargs={"names": names["test"], "data_dir": data_dir, "split": "test"},
271
+ ),
272
+ datasets.SplitGenerator(
273
+ name=datasets.Split.VALIDATION,
274
+ # These kwargs will be passed to _generate_examples
275
+ gen_kwargs={
276
+ "names": names["dev"],
277
+ "data_dir": data_dir,
278
+ "split": "validation",
279
+ },
280
+ ),
281
+ ]
282
+
283
+ def _generate_examples(self, names, data_dir, split):
284
+ """ Yields examples. """
285
+ # The dataset consists of the original article text as well as annotations
286
+ textfile_base_path = os.path.join(data_dir, "texts")
287
+ annotations_base_path = os.path.join(data_dir, "annotations")
288
+
289
+ # The annotations are mostly references to offsets in the source text
290
+ # with corresponding labels, so we'll refer to them as `meta`
291
+ sentence_meta_base_path = os.path.join(annotations_base_path, "sentences")
292
+ tokens_meta_base_path = os.path.join(annotations_base_path, "tokens")
293
+ ets_meta_base_path = os.path.join(annotations_base_path, "entity_types_and_slots")
294
+ frame_meta_base_path = os.path.join(annotations_base_path, "frames")
295
+
296
+ # Define the headers for the sentence and token and entity metadata
297
+ sentence_meta_header = ["sentence_id", "label", "begin_char_offset", "end_char_offset"]
298
+ tokens_meta_header = ["sentence_id", "token_id", "begin_char_offset", "end_char_offset"]
299
+ ets_meta_header = [
300
+ "sentence_id",
301
+ "token_id",
302
+ "begin_char_offset",
303
+ "end_char_offset",
304
+ "entity_label",
305
+ "slot_label",
306
+ ]
307
+
308
+ # Start the processing loop
309
+ # For each text file, we'll load all of the
310
+ # associated annotation files
311
+ for id_, name in enumerate(sorted(names)):
312
+
313
+ # Load the main source text
314
+ textfile_path = os.path.join(textfile_base_path, name + ".txt")
315
+ text = open(textfile_path, encoding="utf-8").read()
316
+
317
+ # Load the sentence offsets file
318
+ sentence_meta_path = os.path.join(sentence_meta_base_path, name + ".csv")
319
+ sentence_meta = pd.read_csv(sentence_meta_path, sep="\t", names=sentence_meta_header)
320
+
321
+ # Load the tokens offsets file
322
+ tokens_meta_path = os.path.join(tokens_meta_base_path, name + ".csv")
323
+ tokens_meta = pd.read_csv(tokens_meta_path, sep="\t", names=tokens_meta_header)
324
+
325
+ # Load the entity offsets file
326
+ ets_meta_path = os.path.join(ets_meta_base_path, name + ".csv")
327
+ ets_meta = pd.read_csv(ets_meta_path, sep="\t", names=ets_meta_header)
328
+
329
+ # Create a list of lists indexed as [sentence][token] for the entity and slot labels
330
+ entity_labels = ets_meta.groupby("sentence_id").apply(lambda x: x["entity_label"].tolist()).to_list()
331
+ slot_labels = ets_meta.groupby("sentence_id").apply(lambda x: x["slot_label"].tolist()).to_list()
332
+
333
+ # Create a list of lists for the token offsets indexed as [sentence][token]
334
+ # Each element will contain a dict with beginning and ending character offsets
335
+ token_offsets = (
336
+ tokens_meta.groupby("sentence_id")[["begin_char_offset", "end_char_offset"]]
337
+ .apply(lambda x: x.to_dict(orient="records"))
338
+ .tolist()
339
+ )
340
+
341
+ # Load the frames metadata. The frames file contains the data for all of the annotations
342
+ # in a condensed format that varies throughout the file. More information on this format
343
+ # can be found: https://framenet.icsi.berkeley.edu/fndrupal/
344
+ frames_meta_path = os.path.join(frame_meta_base_path, name + ".csv")
345
+ frames_meta = open(frames_meta_path, encoding="utf-8").readlines()
346
+
347
+ # Parse the sentence offsets, producing a list of dicts with the
348
+ # starting and ending position of each sentence in the original text
349
+ sentence_offsets = (
350
+ sentence_meta[["begin_char_offset", "end_char_offset"]].apply(lambda x: x.to_dict(), axis=1).tolist()
351
+ )
352
+
353
+ # The sentence labels are a binary label that describes whether the sentence contains
354
+ # any annotations
355
+ sentence_labels = sentence_meta["label"].tolist()
356
+
357
+ # Materialiaze a list of strings of the actual sentences
358
+ sentences = [text[ost["begin_char_offset"] : ost["end_char_offset"]] for ost in sentence_offsets]
359
+
360
+ # Materialize a list of lists of the tokens in each sentence.
361
+ # Annotation labels are aligned with these tokens, so be careful with
362
+ # alignment if using your own tokenization scheme with the sentences above
363
+ tokens = [
364
+ [s[tto["begin_char_offset"] : tto["end_char_offset"]] for tto in to]
365
+ for s, to in zip(sentences, token_offsets)
366
+ ]
367
+
368
+ # The frames file first contains spans annotations (in one format),
369
+ # then contains experiments annotations (in another format),
370
+ # then links annotations (in yet another format).
371
+ # Here we find the beginning of the experiments and links sections of the file
372
+ # Additionally, each experiment annotation in the experiment annotations begins with a
373
+ # line starting with the word EXPERIMENT (in one format)
374
+ # followed by the annotations for that experiment (in yet _another_ format)
375
+ # Here we get the start positions for each experiment _within_ the experiments
376
+ # section of the frames data
377
+ experiment_starts = [i for i, line in enumerate(frames_meta) if line.startswith("EXPERIMENT")]
378
+ experiment_start = min(experiment_starts)
379
+ link_start = min([i for i, line in enumerate(frames_meta) if line.startswith("LINK")])
380
+
381
+ # Pick out the spans section of the data for parsing
382
+ spans_raw = frames_meta[:experiment_start]
383
+
384
+ # Iterate through the spans data
385
+ spans = []
386
+ for span in spans_raw:
387
+
388
+ # Split out the elements in each tab-delimited line
389
+ _, span_id, entity_label_or_exp, sentence_id, begin_char_offset, end_char_offset = span.split("\t")
390
+
391
+ # The entity label for experiment spans have a sub-label,
392
+ # called the experiment mention type,
393
+ # which is sub-delimited by a ':'
394
+ # The code below standardizes the fields produced by
395
+ # each line to a common schema, some fields of which may
396
+ # be empty depending on the data available in the line
397
+ if entity_label_or_exp.startswith("EXPERIMENT"):
398
+ exp, experiment_mention_type = entity_label_or_exp.split(":")
399
+ entity_label = ""
400
+ else:
401
+ entity_label = entity_label_or_exp
402
+ exp = ""
403
+ experiment_mention_type = ""
404
+
405
+ s = {
406
+ "span_id": span_id,
407
+ "entity_label": entity_label,
408
+ "sentence_id": sentence_id,
409
+ "experiment_mention_type": experiment_mention_type,
410
+ "begin_char_offset": int(begin_char_offset),
411
+ "end_char_offset": int(end_char_offset),
412
+ }
413
+ spans.append(s)
414
+
415
+ # Pull out the links annotations for from the frames data
416
+ links_raw = [f.rstrip("\n") for f in frames_meta[link_start:]]
417
+
418
+ # Iterate through the links data, which is in a simple tab-delimited format
419
+ links = []
420
+ for l in links_raw:
421
+ _, relation_label, start_span_id, end_span_id = l.split("\t")
422
+
423
+ link_out = {
424
+ "relation_label": relation_label,
425
+ "start_span_id": int(start_span_id),
426
+ "end_span_id": int(end_span_id),
427
+ }
428
+ links.append(link_out)
429
+
430
+ # Iterate through the experiments data and parse each experiment
431
+ experiments = []
432
+ # Zip the experiment start offsets to get start/end position tuples
433
+ # for each experiment in the experiments data
434
+ for start, end in zip(experiment_starts[:-1], experiment_starts[1:]):
435
+ current_experiment = frames_meta[start:end]
436
+ # The first line of each experiment annotation contains the
437
+ # experiment id and the span id
438
+ _, experiment_id, span_id = current_experiment[0].rstrip("\n").split("\t")
439
+ exp = {"experiment_id": int(experiment_id), "span_id": int(span_id)}
440
+
441
+ # The remaining lines in the experiment annotations contain
442
+ # slot level information for each experiment.
443
+ slots = []
444
+ for e in current_experiment[1:]:
445
+ e = e.rstrip("\n")
446
+ _, frame_participant_label, slot_id = e.split("\t")
447
+ to_add = {"frame_participant_label": frame_participant_label, "slot_id": int(slot_id)}
448
+ slots.append(to_add)
449
+ exp["slots"] = slots
450
+
451
+ experiments.append(exp)
452
+
453
+ # Yield the final parsed example output
454
+ # NOTE: the `token_offsets` is converted to a list of
455
+ # dicts to accommodate processing to the arrow files
456
+ # in the `features` schema defined above
457
+ yield id_, {
458
+ "text": text,
459
+ "sentence_offsets": sentence_offsets,
460
+ "sentences": sentences,
461
+ "sentence_labels": sentence_labels,
462
+ "token_offsets": [{"offsets": to} for to in token_offsets],
463
+ "tokens": tokens,
464
+ "entity_labels": entity_labels,
465
+ "slot_labels": slot_labels,
466
+ "links": links,
467
+ "slots": slots,
468
+ "spans": spans,
469
+ "experiments": experiments,
470
+ }