Datasets:

Languages:
Estonian
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
found
Annotations Creators:
expert-generated
Source Datasets:
original
ArXiv:
License:
phucdev commited on
Commit
43aa529
1 Parent(s): 3ef79b8

Add data files, loading script and update README.md

Browse files
README.md CHANGED
@@ -1,3 +1,220 @@
1
  ---
2
- license: cc-by-nc-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language:
5
+ - et
6
+ language_creators:
7
+ - found
8
+ license:
9
+ - cc-by-nc-4.0
10
+ multilinguality:
11
+ - monolingual
12
+ paperswithcode_id: noisyner
13
+ pretty_name: NoisyNER
14
+ size_categories:
15
+ - 10K<n<100K
16
+ source_datasets:
17
+ - original
18
+ tags:
19
+ - newspapers
20
+ - 1997-2009
21
+ task_categories:
22
+ - token-classification
23
+ task_ids:
24
+ - named-entity-recognition
25
  ---
26
+
27
+ # Dataset Card for NoisyNER
28
+
29
+ ## Table of Contents
30
+ - [Table of Contents](#table-of-contents)
31
+ - [Dataset Description](#dataset-description)
32
+ - [Dataset Summary](#dataset-summary)
33
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
34
+ - [Languages](#languages)
35
+ - [Dataset Structure](#dataset-structure)
36
+ - [Data Instances](#data-instances)
37
+ - [Data Fields](#data-fields)
38
+ - [Data Splits](#data-splits)
39
+ - [Dataset Creation](#dataset-creation)
40
+ - [Curation Rationale](#curation-rationale)
41
+ - [Source Data](#source-data)
42
+ - [Annotations](#annotations)
43
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
44
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
45
+ - [Social Impact of Dataset](#social-impact-of-dataset)
46
+ - [Discussion of Biases](#discussion-of-biases)
47
+ - [Other Known Limitations](#other-known-limitations)
48
+ - [Additional Information](#additional-information)
49
+ - [Dataset Curators](#dataset-curators)
50
+ - [Licensing Information](#licensing-information)
51
+ - [Citation Information](#citation-information)
52
+ - [Contributions](#contributions)
53
+
54
+ ## Dataset Description
55
+
56
+ - **Repository:** [Estonian NER corpus](https://doi.org/10.15155/1-00-0000-0000-0000-00073L), [NoisyNER dataset](https://github.com/uds-lsv/NoisyNER)
57
+ - **Paper:** [Named Entity Recognition in Estonian](https://aclanthology.org/W13-2412/), [Analysing the Noise Model Error for Realistic Noisy Label Data](https://ojs.aaai.org/index.php/AAAI/article/view/16938)
58
+ - **Dataset:** NoisyNER
59
+ - **Domain:** News
60
+
61
+ ### Dataset Summary
62
+
63
+ NoisyNER is a dataset for the evaluation of methods to handle noisy labels when training machine learning models.
64
+
65
+ - Entity Types: `PER`, `ORG`, `LOC`
66
+
67
+ It is from the NLP/Information Extraction domain and was created through a realistic distant supervision technique. Some highlights and interesting aspects of the data are:
68
+
69
+ - Seven sets of labels with differing noise patterns to evaluate different noise levels on the same instances
70
+ - Full parallel clean labels available to compute upper performance bounds or study scenarios where a small amount of gold-standard data can be leveraged
71
+ - Skewed label distribution (typical for Named Entity Recognition tasks)
72
+ - For some label sets: noise level higher than the true label probability
73
+ - Sequential dependencies between the labels
74
+
75
+ For more details on the dataset and its creation process, please refer to the original author's publication https://ojs.aaai.org/index.php/AAAI/article/view/16938 (published at AAAI'21).
76
+
77
+ This dataset is based on the Estonian NER corpus. For more details see https://aclanthology.org/W13-2412/
78
+
79
+ ### Supported Tasks and Leaderboards
80
+
81
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
82
+
83
+ ### Languages
84
+
85
+ The language data in NoisyNER is in Estonian (BCP-47 et)
86
+
87
+ ## Dataset Structure
88
+
89
+ ### Data Instances
90
+
91
+ An example of 'train' looks as follows.
92
+ ```
93
+ {
94
+ 'id': '0',
95
+ 'tokens': ['Tallinna', 'õhusaaste', 'suureneb', '.'],
96
+ 'lemmas': ['Tallinn+0', 'õhu_saaste+0', 'suurene+b', '.'],
97
+ 'grammar': ['_H_ sg g', '_S_ sg n', '_V_ b', '_Z_'],
98
+ 'ner_tags': [5, 0, 0, 0]
99
+ }
100
+ ```
101
+
102
+ ### Data Fields
103
+
104
+ The data fields are the same among all splits.
105
+
106
+ - `id`: a `string` feature.
107
+ - `tokens`: a `list` of `string` features.
108
+ - `lemmas`: a `list` of `string` features.
109
+ - `grammar`: a `list` of `string` features.
110
+ - `ner_tags`: a `list` of classification labels (`int`). Full tagset with indices:
111
+
112
+ ```python
113
+ {'O': 0, 'B-PER': 1, 'I-PER': 2, 'B-ORG': 3, 'I-ORG': 4, 'B-LOC': 5, 'I-LOC': 6}
114
+ ```
115
+
116
+ ### Data Splits
117
+
118
+ The splits are the same across all configurations.
119
+
120
+ |train|validation|test|
121
+ |----:|---------:|---:|
122
+ |11365| 1480|1433|
123
+
124
+ ## Dataset Creation
125
+
126
+ ### Curation Rationale
127
+
128
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
129
+
130
+ ### Source Data
131
+
132
+ #### Initial Data Collection and Normalization
133
+
134
+ Tkachenko et al (2013) collected 572 news stories published in the local online newspapers [Delfi](http://delfi.ee/) and [Postimees](http://postimees.ee/) between 1997 and 2009. Selected articles cover both local and international news on a range of topics including politics, economics and sports. The raw text was preprocessed using the morphological disambiguator t3mesta ([Kaalep and
135
+ Vaino, 1998](https://www.cl.ut.ee/yllitised/kk_yhest_1998.pdf)) provided by [Filosoft](http://www.filosoft.ee/). The processing steps involve tokenization, lemmatization, part-of-speech tagging, grammatical and morphological analysis.
136
+
137
+ #### Who are the source language producers?
138
+
139
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
140
+
141
+ ### Annotations
142
+
143
+ #### Annotation process
144
+
145
+ According to Tkachenko et al (2013) one of the authors manually tagged the corpus and the other author examined the tags, after which conflicting cases were resolved.
146
+ The total size of the corpus is 184,638 tokens. Tkachenko et al (2013) provide the following number of named entities in the corpus:
147
+
148
+ | | PER | LOC | ORG | Total |
149
+ |--------|------|------|------|-------|
150
+ | All | 5762 | 5711 | 3938 | 15411 |
151
+ | Unique | 3588 | 1589 | 1987 | 7164 |
152
+
153
+ Hedderich et al (2021) obtained the noisy labels through a distant supervision/automatic annotation approach. They extracted lists of named entities from Wikidata and matched them against words in the text via the ANEA tool ([Hedderich, Lange, and Klakow 2021](https://arxiv.org/abs/2102.13129)). They also used heuristic functions to correct errors caused by non-complete lists of entities,
154
+ grammatical complexities of Estonian that do not allow simple string matching or entity lists in conflict with each other. For instance, they normalized the grammatical form of a word or excluded certain high false-positive words. They provide seven sets of labels that differ in the noise process. This results in 8 different configurations, when added to the original split with clean labels.
155
+
156
+ #### Who are the annotators?
157
+
158
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
159
+
160
+ ### Personal and Sensitive Information
161
+
162
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
163
+
164
+ ## Considerations for Using the Data
165
+
166
+ ### Social Impact of Dataset
167
+
168
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
169
+
170
+ ### Discussion of Biases
171
+
172
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
173
+
174
+ ### Other Known Limitations
175
+
176
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
177
+
178
+ ## Additional Information
179
+
180
+ ### Dataset Curators
181
+
182
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
183
+
184
+ ### Licensing Information
185
+
186
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
187
+
188
+
189
+ ### Citation Information
190
+
191
+ ```
192
+ @inproceedings{tkachenko-etal-2013-named,
193
+ title = "Named Entity Recognition in {E}stonian",
194
+ author = "Tkachenko, Alexander and
195
+ Petmanson, Timo and
196
+ Laur, Sven",
197
+ booktitle = "Proceedings of the 4th Biennial International Workshop on {B}alto-{S}lavic Natural Language Processing",
198
+ month = aug,
199
+ year = "2013",
200
+ address = "Sofia, Bulgaria",
201
+ publisher = "Association for Computational Linguistics",
202
+ url = "https://aclanthology.org/W13-2412",
203
+ pages = "78--83",
204
+ }
205
+ @article{Hedderich_Zhu_Klakow_2021,
206
+ title={Analysing the Noise Model Error for Realistic Noisy Label Data},
207
+ author={Hedderich, Michael A. and Zhu, Dawei and Klakow, Dietrich},
208
+ volume={35},
209
+ url={https://ojs.aaai.org/index.php/AAAI/article/view/16938},
210
+ number={9},
211
+ journal={Proceedings of the AAAI Conference on Artificial Intelligence},
212
+ year={2021},
213
+ month={May},
214
+ pages={7675-7684},
215
+ }
216
+ ```
217
+
218
+ ### Contributions
219
+
220
+ Thanks to [@phucdev](https://github.com/phucdev) for adding this dataset.
data/NoisyNER_labelset1_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset1_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset1_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset1_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset2_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset2_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset2_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset2_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset3_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset3_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset3_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset3_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset4_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset4_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset4_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset4_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset5_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset5_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset5_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset5_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset6_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset6_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset6_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset6_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset7_all.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset7_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset7_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/NoisyNER_labelset7_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/estner_clean_dev.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/estner_clean_test.tsv ADDED
The diff for this file is too large to render. See raw diff
 
data/estner_clean_train.tsv ADDED
The diff for this file is too large to render. See raw diff
 
noisyner.py ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ logger = datasets.logging.get_logger(__name__)
5
+
6
+ # Find for instance the citation on arxiv or on the dataset repo/website
7
+ _CITATION = """\
8
+ @inproceedings{hedderich2021analysing,
9
+ title={Analysing the Noise Model Error for Realistic Noisy Label Data},
10
+ author={Hedderich, Michael A and Zhu, Dawei and Klakow, Dietrich},
11
+ booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
12
+ volume={35},
13
+ number={9},
14
+ pages={7675--7684},
15
+ year={2021}
16
+ }
17
+ @inproceedings{tkachenko-etal-2013-named,
18
+ title = "Named Entity Recognition in {E}stonian",
19
+ author = "Tkachenko, Alexander and Petmanson, Timo and Laur, Sven",
20
+ booktitle = "Proceedings of the 4th Biennial International Workshop on {B}alto-{S}lavic Natural Language Processing",
21
+ year = "2013",
22
+ publisher = "Association for Computational Linguistics",
23
+ url = "https://www.aclweb.org/anthology/W13-2412",
24
+ }
25
+ """
26
+
27
+ # You can copy an official description
28
+ _DESCRIPTION = """\
29
+ NoisyNER is a dataset for the evaluation of methods to handle noisy labels when training machine learning models.
30
+ It is from the NLP/Information Extraction domain and was created through a realistic distant supervision technique.
31
+ Some highlights and interesting aspects of the data are:
32
+ - Seven sets of labels with differing noise patterns to evaluate different noise levels on the same instances
33
+ - Full parallel clean labels available to compute upper performance bounds or study scenarios where a small amount of
34
+ gold-standard data can be leveraged
35
+ - Skewed label distribution (typical for Named Entity Recognition tasks)
36
+ - For some label sets: noise level higher than the true label probability
37
+ - Sequential dependencies between the labels
38
+
39
+ For more details on the dataset and its creation process, please refer to our publication
40
+ https://ojs.aaai.org/index.php/AAAI/article/view/16938 (published at AAAI'21).
41
+ """
42
+
43
+ _HOMEPAGE = "https://github.com/uds-lsv/NoisyNER"
44
+
45
+ _LICENSE = "The original dataset is licensed under CC-BY-NC. We provide our noisy labels under CC-BY 4.0."
46
+
47
+ _URL = "https://huggingface.co/datasets/phuctrg/noisyner/raw/main/data"
48
+
49
+
50
+ class NoisyNER(datasets.GeneratorBasedBuilder):
51
+ """
52
+ NoisyNER is a dataset for the evaluation of methods to handle noisy labels when training machine learning models.
53
+ """
54
+
55
+ VERSION = datasets.Version("1.0.0")
56
+ BUILDER_CONFIGS = [
57
+ datasets.BuilderConfig(
58
+ name="estner_clean", version=VERSION, description="EstNER dataset with clean labels"
59
+ ),
60
+ datasets.BuilderConfig(
61
+ name="NoisyNER_labelset1", version=VERSION,
62
+ description="NoisyNER dataset label set 1 "
63
+ "with automatic annotation via distant supervision based ANEA tool with no heuristics"
64
+ ),
65
+ datasets.BuilderConfig(
66
+ name="NoisyNER_labelset2", version=VERSION,
67
+ description="NoisyNER dataset label set 2 "
68
+ "with automatic annotation via distant supervision based ANEA tool and "
69
+ "applying Estonian lemmatization to normalize the words"
70
+ ),
71
+ datasets.BuilderConfig(
72
+ name="NoisyNER_labelset3", version=VERSION,
73
+ description="NoisyNER dataset label set 3 "
74
+ "with automatic annotation via distant supervision based ANEA tool and "
75
+ "splitting person entity names in the list, i.e. both first and last names can be matched "
76
+ "separately. Person names must have a minimum length of 4. Also, lemmatization"
77
+ ),
78
+ datasets.BuilderConfig(
79
+ name="NoisyNER_labelset4", version=VERSION,
80
+ description="NoisyNER dataset label set 4 "
81
+ "with automatic annotation via distant supervision based ANEA tool and if entity names from "
82
+ "two different lists match the same word, location entities are preferred. "
83
+ "Also, lemmatization."
84
+ ),
85
+ datasets.BuilderConfig(
86
+ name="NoisyNER_labelset5", version=VERSION,
87
+ description="NoisyNER dataset label set 5 "
88
+ "with automatic annotation via distant supervision based ANEA tool and "
89
+ "Locations preferred, lemmatization, splitting names with minimum length 4."
90
+ ),
91
+ datasets.BuilderConfig(
92
+ name="NoisyNER_labelset6", version=VERSION,
93
+ description="NoisyNER dataset label set 6 "
94
+ "with automatic annotation via distant supervision based ANEA tool and "
95
+ "removing the entity names 'kohta', 'teine', 'naine' and 'mees' from the list of person names "
96
+ "(high false positive rate). Also, all of label set 5."
97
+ ),
98
+ datasets.BuilderConfig(
99
+ name="NoisyNER_labelset7", version=VERSION,
100
+ description="NoisyNER dataset label set 7 "
101
+ "with automatic annotation via distant supervision based ANEA tool and using alternative, "
102
+ "alias names for organizations. Using additionally the identifiers Q82794, Q3957, Q7930989, "
103
+ "Q5119 and Q11881845 for locations and Q1572070 and Q7278 for organizations. "
104
+ "Also, all of label set 6."
105
+ ),
106
+ ]
107
+
108
+ DEFAULT_CONFIG_NAME = "estner_clean"
109
+
110
+ def _info(self):
111
+ features = datasets.Features(
112
+ {
113
+ "id": datasets.Value("string"),
114
+ "tokens": datasets.Sequence(datasets.Value("string")),
115
+ "lemmas": datasets.Sequence(datasets.Value("string")),
116
+ "grammar": datasets.Sequence(datasets.Value("string")),
117
+ "ner_tags": datasets.Sequence(
118
+ datasets.features.ClassLabel(
119
+ names=[
120
+ "O",
121
+ "B-PER",
122
+ "I-PER",
123
+ "B-ORG",
124
+ "I-ORG",
125
+ "B-LOC",
126
+ "I-LOC"
127
+ ]
128
+ )
129
+ ),
130
+ }
131
+ )
132
+ return datasets.DatasetInfo(
133
+ # This is the description that will appear on the datasets page.
134
+ description=_DESCRIPTION,
135
+ # This defines the different columns of the dataset and their types
136
+ features=features, # Here we define them above because they are different between the two configurations
137
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
138
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
139
+ # supervised_keys=("sentence", "label"),
140
+ # Homepage of the dataset for documentation
141
+ homepage=_HOMEPAGE,
142
+ # License for the dataset if available
143
+ license=_LICENSE,
144
+ # Citation for the dataset
145
+ citation=_CITATION,
146
+ )
147
+
148
+ def _split_generators(self, dl_manager):
149
+ _URLS = {
150
+ str(datasets.Split.TRAIN): f'{_URL}/{self.config.name}_train.tsv',
151
+ str(datasets.Split.VALIDATION): f'{_URL}/{self.config.name}_dev.tsv',
152
+ str(datasets.Split.TEST): f'{_URL}/{self.config.name}_test.tsv',
153
+ }
154
+
155
+ downloaded_files = dl_manager.download_and_extract(_URLS)
156
+
157
+ return [datasets.SplitGenerator(name=i, gen_kwargs={"filepath": downloaded_files[str(i)]})
158
+ for i in [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]]
159
+
160
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
161
+ def _generate_examples(self, filepath):
162
+ logger.info("⏳ Generating examples from = %s", filepath)
163
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
164
+ with open(filepath, encoding="utf-8") as f:
165
+ guid = 0
166
+ tokens = []
167
+ lemmas = []
168
+ grammar_infos = []
169
+ ner_tags = []
170
+ for line in f:
171
+ if line in ["--", "", "\n", "--\n"]:
172
+ if tokens:
173
+ yield guid, {
174
+ "id": str(guid),
175
+ "tokens": tokens,
176
+ "lemmas": lemmas,
177
+ "grammar": grammar_infos,
178
+ "ner_tags": ner_tags,
179
+ }
180
+ guid += 1
181
+ tokens = []
182
+ lemmas = []
183
+ grammar_infos = []
184
+ ner_tags = []
185
+ else:
186
+ splits = line.split("\t")
187
+ tokens.append(splits[0])
188
+ lemmas.append(splits[1])
189
+ grammar_infos.append(splits[2])
190
+ ner_tags.append(splits[3].rstrip())
191
+ # last example
192
+ if tokens:
193
+ yield guid, {
194
+ "id": str(guid),
195
+ "tokens": tokens,
196
+ "lemmas": lemmas,
197
+ "grammar": grammar_infos,
198
+ "ner_tags": ner_tags,
199
+ }