urbija commited on
Commit
0f218f8
1 Parent(s): 440c34a

initial commit

Browse files
Files changed (2) hide show
  1. README.md +182 -0
  2. mobie.py +215 -0
README.md ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - de
8
+ licenses:
9
+ - cc-by-4.0
10
+ multilinguality:
11
+ - monolingual
12
+ paperswithcode_id: mobie
13
+ pretty_name: MobIE
14
+ size_categories:
15
+ - 10K<n<100K
16
+ source_datasets:
17
+ - original
18
+ task_categories:
19
+ - structure-prediction
20
+ task_ids:
21
+ - named-entity-recognition
22
+ ---
23
+
24
+ # Dataset Card for "MobIE"
25
+
26
+ ## Table of Contents
27
+ - [Dataset Description](#dataset-description)
28
+ - [Dataset Summary](#dataset-summary)
29
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
30
+ - [Languages](#languages)
31
+ - [Dataset Structure](#dataset-structure)
32
+ - [Data Instances](#data-instances)
33
+ - [Data Fields](#data-fields)
34
+ - [Data Splits](#data-splits)
35
+ - [Dataset Creation](#dataset-creation)
36
+ - [Curation Rationale](#curation-rationale)
37
+ - [Source Data](#source-data)
38
+ - [Annotations](#annotations)
39
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
40
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
41
+ - [Social Impact of Dataset](#social-impact-of-dataset)
42
+ - [Discussion of Biases](#discussion-of-biases)
43
+ - [Other Known Limitations](#other-known-limitations)
44
+ - [Additional Information](#additional-information)
45
+ - [Dataset Curators](#dataset-curators)
46
+ - [Licensing Information](#licensing-information)
47
+ - [Citation Information](#citation-information)
48
+ - [Contributions](#contributions)
49
+
50
+ ## Dataset Description
51
+
52
+ - **Homepage:** [https://github.com/dfki-nlp/mobie](https://github.com/dfki-nlp/mobie)
53
+ - **Repository:** [https://github.com/dfki-nlp/mobie](https://github.com/dfki-nlp/mobie)
54
+ - **Paper:** [https://aclanthology.org/2021.konvens-1.22/](https://aclanthology.org/2021.konvens-1.22/)
55
+ - **Point of Contact:** See [https://github.com/dfki-nlp/mobie](https://github.com/dfki-nlp/mobie)
56
+
57
+ ### Dataset Summary
58
+
59
+ This script is for loading the MobIE dataset from https://github.com/dfki-nlp/mobie.
60
+
61
+ MobIE is a German-language dataset which is human-annotated with 20 coarse- and fine-grained entity types and entity linking information for geographically linkable entities. The dataset consists of 3,232 social media texts and traffic reports with 91K tokens, and contains 20.5K annotated entities, 13.1K of which are linked to a knowledge base. A subset of the dataset is human-annotated with seven mobility-related, n-ary relation types, while the remaining documents are annotated using a weakly-supervised labeling approach implemented with the Snorkel framework. The dataset combines annotations for NER, EL and RE, and thus can be used for joint and multi-task learning of these fundamental information extraction tasks.
62
+
63
+ This version of the dataset loader provides NER tags only. NER tags use the `BIO` tagging scheme.
64
+
65
+ For more details see https://github.com/dfki-nlp/mobie and https://aclanthology.org/2021.konvens-1.22/.
66
+
67
+ ### Supported Tasks and Leaderboards
68
+
69
+ - **Tasks:** Named Entity Recognition
70
+ - **Leaderboards:**
71
+
72
+ ### Languages
73
+
74
+ German
75
+
76
+ ## Dataset Structure
77
+
78
+ ### Data Instances
79
+
80
+ - **Size of downloaded dataset files:** 7.8 MB
81
+ - **Size of the generated dataset:** 1.7 MB
82
+ - **Total amount of disk used:** 9.5 MB
83
+
84
+ An example of 'train' looks as follows.
85
+
86
+ ```json
87
+ {
88
+ 'id': 'http://www.ndr.de/nachrichten/verkehr/index.html#2@2016-05-04T21:02:14.000+02:00',
89
+ 'tokens': ['Vorsicht', 'bitte', 'auf', 'der', 'A28', 'Leer', 'Richtung', 'Oldenburg', 'zwischen', 'Zwischenahner', 'Meer', 'und', 'Neuenkruge', 'liegen', 'Gegenstände', '!'],
90
+ 'ner_tags': [0, 0, 0, 0, 19, 13, 0, 13, 0, 11, 12, 0, 11, 0, 0, 0]
91
+ }
92
+ ```
93
+
94
+
95
+ ### Data Fields
96
+
97
+ The data fields are the same among all splits.
98
+
99
+ - `id`: a `string` feature.
100
+ - `tokens`: a `list` of `string` features.
101
+ - `ner_tags`: a `list` of classification labels, with possible values including `O` (0), `B-date` (1), `I-date` (2), `B-disaster-type` (3), `I-disaster-type` (4), ...
102
+
103
+ ### Data Splits
104
+
105
+ | | Train | Dev | Test |
106
+ | ----- | ------ | ----- | ---- |
107
+ | MobIE | 4785 | 1082 | 1210 |
108
+
109
+ ## Dataset Creation
110
+
111
+ ### Curation Rationale
112
+
113
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
114
+
115
+ ### Source Data
116
+
117
+ #### Initial Data Collection and Normalization
118
+
119
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
120
+
121
+ #### Who are the source language producers?
122
+
123
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
124
+
125
+ ### Annotations
126
+
127
+ #### Annotation process
128
+
129
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
130
+
131
+ #### Who are the annotators?
132
+
133
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
134
+
135
+ ### Personal and Sensitive Information
136
+
137
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
138
+
139
+ ## Considerations for Using the Data
140
+
141
+ ### Social Impact of Dataset
142
+
143
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
144
+
145
+ ### Discussion of Biases
146
+
147
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
148
+
149
+ ### Other Known Limitations
150
+
151
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
152
+
153
+ ## Additional Information
154
+
155
+ ### Dataset Curators
156
+
157
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
158
+
159
+ ### Licensing Information
160
+
161
+ [CC BY-SA 4.0 license](https://creativecommons.org/licenses/by-sa/4.0/)
162
+
163
+ ### Citation Information
164
+
165
+ ```
166
+ @inproceedings{hennig-etal-2021-mobie,
167
+ title = "{M}ob{IE}: A {G}erman Dataset for Named Entity Recognition, Entity Linking and Relation Extraction in the Mobility Domain",
168
+ author = "Hennig, Leonhard and
169
+ Truong, Phuc Tran and
170
+ Gabryszak, Aleksandra",
171
+ booktitle = "Proceedings of the 17th Conference on Natural Language Processing (KONVENS 2021)",
172
+ month = "6--9 " # sep,
173
+ year = "2021",
174
+ address = {D{\"u}sseldorf, Germany},
175
+ publisher = "KONVENS 2021 Organizers",
176
+ url = "https://aclanthology.org/2021.konvens-1.22",
177
+ pages = "223--227",
178
+ }
179
+ ```
180
+
181
+
182
+ ### Contributions
mobie.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """\
16
+ MobIE is a German-language dataset which is human-annotated with 20 coarse- and fine-grained entity types and entity linking information for geographically linkable entities. The dataset consists of 3,232 social media texts and traffic reports with 91K tokens, and contains 20.5K annotated entities, 13.1K of which are linked to a knowledge base. A subset of the dataset is human-annotated with seven mobility-related, n-ary relation types, while the remaining documents are annotated using a weakly-supervised labeling approach implemented with the Snorkel framework. The dataset combines annotations for NER, EL and RE, and thus can be used for joint and multi-task learning of these fundamental information extraction tasks."""
17
+
18
+ import re
19
+ from json import JSONDecodeError, JSONDecoder
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """\
25
+ @inproceedings{hennig-etal-2021-mobie,
26
+ title = "{M}ob{IE}: A {G}erman Dataset for Named Entity Recognition, Entity Linking and Relation Extraction in the Mobility Domain",
27
+ author = "Hennig, Leonhard and
28
+ Truong, Phuc Tran and
29
+ Gabryszak, Aleksandra",
30
+ booktitle = "Proceedings of the 17th Conference on Natural Language Processing (KONVENS 2021)",
31
+ month = "6--9 " # sep,
32
+ year = "2021",
33
+ address = {D{\"u}sseldorf, Germany},
34
+ publisher = "KONVENS 2021 Organizers",
35
+ url = "https://aclanthology.org/2021.konvens-1.22",
36
+ pages = "223--227",
37
+ }
38
+ """
39
+
40
+ _DESCRIPTION = """\
41
+ MobIE is a German-language dataset which is human-annotated with 20 coarse- and fine-grained entity types and entity linking information for geographically linkable entities. The dataset consists of 3,232 social media texts and traffic reports with 91K tokens, and contains 20.5K annotated entities, 13.1K of which are linked to a knowledge base. A subset of the dataset is human-annotated with seven mobility-related, n-ary relation types, while the remaining documents are annotated using a weakly-supervised labeling approach implemented with the Snorkel framework. The dataset combines annotations for NER, EL and RE, and thus can be used for joint and multi-task learning of these fundamental information extraction tasks."""
42
+
43
+ _HOMEPAGE = "https://github.com/dfki-nlp/mobie"
44
+
45
+ _LICENSE = "CC-BY 4.0"
46
+
47
+ _URLs = {
48
+ "train": "https://github.com/DFKI-NLP/MobIE/raw/master/v1_20210811/train.jsonl.gz",
49
+ "dev": "https://github.com/DFKI-NLP/MobIE/raw/master/v1_20210811/dev.jsonl.gz",
50
+ "test": "https://github.com/DFKI-NLP/MobIE/raw/master/v1_20210811/test.jsonl.gz",
51
+ }
52
+
53
+
54
+ class Mobie(datasets.GeneratorBasedBuilder):
55
+ """MobIE is a German-language dataset which is human-annotated with 20 coarse- and fine-grained entity types and entity linking information for geographically linkable entities"""
56
+
57
+ VERSION = datasets.Version("1.0.0")
58
+
59
+ # This is an example of a dataset with multiple configurations.
60
+ # If you don't want/need to define several sub-sets in your dataset,
61
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
62
+
63
+ # If you need to make complex sub-parts in the datasets with configurable options
64
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
65
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
66
+
67
+ # You will be able to load one or the other configurations in the following list with
68
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
69
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
70
+ BUILDER_CONFIGS = [
71
+ datasets.BuilderConfig(name="mobie-v1_20210811", version=VERSION, description="MobIE V1"),
72
+ ]
73
+
74
+ def _info(self):
75
+ features = datasets.Features(
76
+ {
77
+ "id": datasets.Value("string"),
78
+ "tokens": datasets.Sequence(datasets.Value("string")),
79
+ "ner_tags": datasets.Sequence(
80
+ datasets.features.ClassLabel(
81
+ names=[
82
+ "O",
83
+ "B-date",
84
+ "I-date",
85
+ "B-disaster-type",
86
+ "I-disaster-type",
87
+ "B-distance",
88
+ "I-distance",
89
+ "B-duration",
90
+ "I-duration",
91
+ "B-event-cause",
92
+ "I-event-cause",
93
+ "B-location",
94
+ "I-location",
95
+ "B-location-city",
96
+ "I-location-city",
97
+ "B-location-route",
98
+ "I-location-route",
99
+ "B-location-stop",
100
+ "I-location-stop",
101
+ "B-location-street",
102
+ "I-location-street",
103
+ "B-money",
104
+ "I-money",
105
+ "B-number",
106
+ "I-number",
107
+ "B-organization",
108
+ "I-organization",
109
+ "B-organization-company",
110
+ "I-organization-company",
111
+ "B-org-position",
112
+ "I-org-position",
113
+ "B-percent",
114
+ "I-percent",
115
+ "B-person",
116
+ "I-person",
117
+ "B-set",
118
+ "I-set",
119
+ "B-time",
120
+ "I-time",
121
+ "B-trigger",
122
+ "I-trigger",
123
+ ]
124
+ )
125
+ ),
126
+ }
127
+ )
128
+
129
+ return datasets.DatasetInfo(
130
+ # This is the description that will appear on the datasets page.
131
+ description=_DESCRIPTION,
132
+ # This defines the different columns of the dataset and their types
133
+ features=features, # Here we define them above because they are different between the two configurations
134
+ # If there's a common (input, target) tuple from the features,
135
+ # specify them here. They'll be used if as_supervised=True in
136
+ # builder.as_dataset.
137
+ supervised_keys=None,
138
+ # Homepage of the dataset for documentation
139
+ homepage=_HOMEPAGE,
140
+ # License for the dataset if available
141
+ license=_LICENSE,
142
+ # Citation for the dataset
143
+ citation=_CITATION,
144
+ )
145
+
146
+ def _split_generators(self, dl_manager):
147
+ """Returns SplitGenerators."""
148
+
149
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
150
+ # 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.
151
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
152
+ data_dir = dl_manager.download_and_extract(_URLs)
153
+ return [
154
+ datasets.SplitGenerator(
155
+ name=datasets.Split.TRAIN,
156
+ # These kwargs will be passed to _generate_examples
157
+ gen_kwargs={"filepath": data_dir["train"], "split": "train"},
158
+ ),
159
+ datasets.SplitGenerator(
160
+ name=datasets.Split.TEST,
161
+ # These kwargs will be passed to _generate_examples
162
+ gen_kwargs={"filepath": data_dir["test"], "split": "test"},
163
+ ),
164
+ datasets.SplitGenerator(
165
+ name=datasets.Split.VALIDATION,
166
+ # These kwargs will be passed to _generate_examples
167
+ gen_kwargs={"filepath": data_dir["dev"], "split": "dev"},
168
+ ),
169
+ ]
170
+
171
+ def _generate_examples(self, filepath, split):
172
+ """Yields examples."""
173
+
174
+ NOT_WHITESPACE = re.compile(r"[^\s]")
175
+
176
+ def decode_stacked(document, pos=0, decoder=JSONDecoder()):
177
+ while True:
178
+ match = NOT_WHITESPACE.search(document, pos)
179
+ if not match:
180
+ return
181
+ pos = match.start()
182
+ try:
183
+ obj, pos = decoder.raw_decode(document, pos)
184
+ except JSONDecodeError:
185
+ raise
186
+ yield obj
187
+
188
+ with open(filepath, encoding="utf-8") as f:
189
+ raw = f.read()
190
+
191
+ for doc in decode_stacked(raw):
192
+ text = doc["text"]["string"]
193
+
194
+
195
+ entity_starts = []
196
+ for m in doc["conceptMentions"]["array"]:
197
+ entity_starts.append(m["span"]["start"])
198
+ for s in doc["sentences"]["array"]:
199
+ toks = []
200
+ lbls = []
201
+ sid = s["id"]
202
+ for x in s["tokens"]["array"]:
203
+ toks.append(text[x["span"]["start"] : x["span"]["end"]])
204
+ # convert to BIO
205
+ if x["ner"]["string"] != 'O':
206
+ lbls.append("B-" + x["ner"]["string"] if x["span"]["start"] in entity_starts else "I-" + x["ner"]["string"])
207
+ else:
208
+ lbls.append(x["ner"]["string"])
209
+
210
+ yield sid, {
211
+ "id": sid,
212
+ "tokens": toks,
213
+ "ner_tags": lbls,
214
+ }
215
+