Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
Finnish
Size:
10K<n<100K
ArXiv:
License:
Commit
ยท
17d5bb3
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +152 -0
- dataset_infos.json +1 -0
- dummy/finer/1.0.0/dummy_data.zip +3 -0
- finer.py +186 -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,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- other
|
6 |
+
languages:
|
7 |
+
- fi
|
8 |
+
licenses:
|
9 |
+
- mit
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 1K<n<10K
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- structure-prediction
|
18 |
+
task_ids:
|
19 |
+
- named-entity-recognition
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for [Dataset Name]
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
- [Dataset Description](#dataset-description)
|
26 |
+
- [Dataset Summary](#dataset-summary)
|
27 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
28 |
+
- [Languages](#languages)
|
29 |
+
- [Dataset Structure](#dataset-structure)
|
30 |
+
- [Data Instances](#data-instances)
|
31 |
+
- [Data Fields](#data-instances)
|
32 |
+
- [Data Splits](#data-instances)
|
33 |
+
- [Dataset Creation](#dataset-creation)
|
34 |
+
- [Curation Rationale](#curation-rationale)
|
35 |
+
- [Source Data](#source-data)
|
36 |
+
- [Annotations](#annotations)
|
37 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
38 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
39 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
40 |
+
- [Discussion of Biases](#discussion-of-biases)
|
41 |
+
- [Other Known Limitations](#other-known-limitations)
|
42 |
+
- [Additional Information](#additional-information)
|
43 |
+
- [Dataset Curators](#dataset-curators)
|
44 |
+
- [Licensing Information](#licensing-information)
|
45 |
+
- [Citation Information](#citation-information)
|
46 |
+
|
47 |
+
## Dataset Description
|
48 |
+
|
49 |
+
- **Homepage:** [Github](https://github.com/mpsilfve/finer-data)
|
50 |
+
- **Repository:** [Github](https://github.com/mpsilfve/finer-data)
|
51 |
+
- **Paper:** [Arxiv](https://arxiv.org/abs/1908.04212)
|
52 |
+
- **Leaderboard:**
|
53 |
+
- **Point of Contact:**
|
54 |
+
|
55 |
+
### Dataset Summary
|
56 |
+
|
57 |
+
[More Information Needed]
|
58 |
+
|
59 |
+
### Supported Tasks and Leaderboards
|
60 |
+
|
61 |
+
[More Information Needed]
|
62 |
+
|
63 |
+
### Languages
|
64 |
+
|
65 |
+
[More Information Needed]
|
66 |
+
|
67 |
+
## Dataset Structure
|
68 |
+
|
69 |
+
### Data Instances
|
70 |
+
|
71 |
+
[More Information Needed]
|
72 |
+
|
73 |
+
### Data Fields
|
74 |
+
|
75 |
+
Each row consists of the following fields:
|
76 |
+
|
77 |
+
* `id`: The sentence id
|
78 |
+
* `tokens`: An ordered list of tokens from the full text
|
79 |
+
* `ner_tags`: Named entity recognition tags for each token
|
80 |
+
* `nested_ner_tags`: Nested named entity recognition tags for each token
|
81 |
+
|
82 |
+
Note that by design, the length of `tokens`, `ner_tags`, and `nested_ner_tags` will always be identical.
|
83 |
+
|
84 |
+
`ner_tags` and `nested_ner_tags` correspond to the list below:
|
85 |
+
|
86 |
+
```
|
87 |
+
[ "O", "B-DATE", "B-EVENT", "B-LOC", "B-ORG", "B-PER", "B-PRO", "I-DATE", "I-EVENT", "I-LOC", "I-ORG", "I-PER", "I-PRO" ]
|
88 |
+
```
|
89 |
+
|
90 |
+
IOB2 labeling scheme is used.
|
91 |
+
|
92 |
+
### Data Splits
|
93 |
+
|
94 |
+
[More Information Needed]
|
95 |
+
|
96 |
+
## Dataset Creation
|
97 |
+
|
98 |
+
### Curation Rationale
|
99 |
+
|
100 |
+
[More Information Needed]
|
101 |
+
|
102 |
+
### Source Data
|
103 |
+
|
104 |
+
#### Initial Data Collection and Normalization
|
105 |
+
|
106 |
+
[More Information Needed]
|
107 |
+
|
108 |
+
#### Who are the source language producers?
|
109 |
+
|
110 |
+
[More Information Needed]
|
111 |
+
|
112 |
+
### Annotations
|
113 |
+
|
114 |
+
#### Annotation process
|
115 |
+
|
116 |
+
[More Information Needed]
|
117 |
+
|
118 |
+
#### Who are the annotators?
|
119 |
+
|
120 |
+
[More Information Needed]
|
121 |
+
|
122 |
+
### Personal and Sensitive Information
|
123 |
+
|
124 |
+
[More Information Needed]
|
125 |
+
|
126 |
+
## Considerations for Using the Data
|
127 |
+
|
128 |
+
### Social Impact of Dataset
|
129 |
+
|
130 |
+
[More Information Needed]
|
131 |
+
|
132 |
+
### Discussion of Biases
|
133 |
+
|
134 |
+
[More Information Needed]
|
135 |
+
|
136 |
+
### Other Known Limitations
|
137 |
+
|
138 |
+
[More Information Needed]
|
139 |
+
|
140 |
+
## Additional Information
|
141 |
+
|
142 |
+
### Dataset Curators
|
143 |
+
|
144 |
+
[More Information Needed]
|
145 |
+
|
146 |
+
### Licensing Information
|
147 |
+
|
148 |
+
[More Information Needed]
|
149 |
+
|
150 |
+
### Citation Information
|
151 |
+
|
152 |
+
[More Information Needed]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"finer": {"description": "The directory data contains a corpus of Finnish technology related news articles with a manually prepared\nnamed entity annotation (digitoday.2014.csv). The text material was extracted from the archives of Digitoday,\na Finnish online technology news source (www.digitoday.fi). The corpus consists of 953 articles\n(193,742 word tokens) with six named entity classes (organization, location, person, product, event, and date).\nThe corpus is available for research purposes and can be readily used for development of NER systems for Finnish.\n", "citation": "@article{ruokolainen2019finnish,\n title={A finnish news corpus for named entity recognition},\n author={Ruokolainen, Teemu and Kauppinen, Pekka and Silfverberg, Miikka and Lind{'e}n, Krister},\n journal={Language Resources and Evaluation},\n pages={1--26},\n year={2019},\n publisher={Springer}\n}\n", "homepage": "https://github.com/mpsilfve/finer-data", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 13, "names": ["O", "B-DATE", "B-EVENT", "B-LOC", "B-ORG", "B-PER", "B-PRO", "I-DATE", "I-EVENT", "I-LOC", "I-ORG", "I-PER", "I-PRO"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}, "nested_ner_tags": {"feature": {"num_classes": 13, "names": ["O", "B-DATE", "B-EVENT", "B-LOC", "B-ORG", "B-PER", "B-PRO", "I-DATE", "I-EVENT", "I-LOC", "I-ORG", "I-PER", "I-PRO"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "finer", "config_name": "finer", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5159550, "num_examples": 13497, "dataset_name": "finer"}, "validation": {"name": "validation", "num_bytes": 387494, "num_examples": 986, "dataset_name": "finer"}, "test": {"name": "test", "num_bytes": 1327354, "num_examples": 3512, "dataset_name": "finer"}, "test_wikipedia": {"name": "test_wikipedia", "num_bytes": 1404397, "num_examples": 3360, "dataset_name": "finer"}}, "download_checksums": {"https://github.com/mpsilfve/finer-data/raw/master/data/digitoday.2014.train.csv": {"num_bytes": 2300198, "checksum": "9a0c219f13bb222081f2c91bef8ed40e0b5e229c5be9c467d19ab99bda806eb6"}, "https://github.com/mpsilfve/finer-data/raw/master/data/digitoday.2014.dev.csv": {"num_bytes": 173297, "checksum": "8400f95bcfac52a2baab9529c5859525a2a2b6bbd5734418b83ed0ad593ea219"}, "https://github.com/mpsilfve/finer-data/raw/master/data/digitoday.2015.test.csv": {"num_bytes": 609432, "checksum": "c5947ac6f760ffa56248849c77129b8a2efefd1230af62e0487fd96caf4a2fee"}, "https://github.com/mpsilfve/finer-data/raw/master/data/wikipedia.test.csv": {"num_bytes": 650200, "checksum": "8a46e90e5ac3c1beff9e46f02d8275b7ce7573efaeb7b780ba7e827b404a0820"}}, "download_size": 3733127, "post_processing_size": null, "dataset_size": 8278795, "size_in_bytes": 12011922}}
|
dummy/finer/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e4f00a911d5c4e28357ee4a26cfb9c15e77b2997fbabb8ee62f9445d86ed50e8
|
3 |
+
size 874
|
finer.py
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
""""The Finnish News Corpus for Named Entity Recognition dataset."""
|
18 |
+
|
19 |
+
from __future__ import absolute_import, division, print_function
|
20 |
+
|
21 |
+
import csv
|
22 |
+
import logging
|
23 |
+
|
24 |
+
import datasets
|
25 |
+
|
26 |
+
|
27 |
+
_CITATION = """\
|
28 |
+
@article{ruokolainen2019finnish,
|
29 |
+
title={A finnish news corpus for named entity recognition},
|
30 |
+
author={Ruokolainen, Teemu and Kauppinen, Pekka and Silfverberg, Miikka and Lind{\'e}n, Krister},
|
31 |
+
journal={Language Resources and Evaluation},
|
32 |
+
pages={1--26},
|
33 |
+
year={2019},
|
34 |
+
publisher={Springer}
|
35 |
+
}
|
36 |
+
"""
|
37 |
+
|
38 |
+
_DESCRIPTION = """\
|
39 |
+
The directory data contains a corpus of Finnish technology related news articles with a manually prepared
|
40 |
+
named entity annotation (digitoday.2014.csv). The text material was extracted from the archives of Digitoday,
|
41 |
+
a Finnish online technology news source (www.digitoday.fi). The corpus consists of 953 articles
|
42 |
+
(193,742 word tokens) with six named entity classes (organization, location, person, product, event, and date).
|
43 |
+
The corpus is available for research purposes and can be readily used for development of NER systems for Finnish.
|
44 |
+
"""
|
45 |
+
|
46 |
+
_URLS = {
|
47 |
+
"train": "https://github.com/mpsilfve/finer-data/raw/master/data/digitoday.2014.train.csv",
|
48 |
+
"dev": "https://github.com/mpsilfve/finer-data/raw/master/data/digitoday.2014.dev.csv",
|
49 |
+
"test": "https://github.com/mpsilfve/finer-data/raw/master/data/digitoday.2015.test.csv",
|
50 |
+
"test_wikipedia": "https://github.com/mpsilfve/finer-data/raw/master/data/wikipedia.test.csv",
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
class FinerConfig(datasets.BuilderConfig):
|
55 |
+
"""BuilderConfig for FiNER dataset."""
|
56 |
+
|
57 |
+
def __init__(self, **kwargs):
|
58 |
+
"""BuilderConfig for FiNER dataset.
|
59 |
+
|
60 |
+
Args:
|
61 |
+
**kwargs: keyword arguments forwarded to super.
|
62 |
+
"""
|
63 |
+
super(FinerConfig, self).__init__(**kwargs)
|
64 |
+
|
65 |
+
|
66 |
+
class Finer(datasets.GeneratorBasedBuilder):
|
67 |
+
"""FiNER dataset."""
|
68 |
+
|
69 |
+
BUILDER_CONFIGS = [
|
70 |
+
FinerConfig(
|
71 |
+
name="finer",
|
72 |
+
version=datasets.Version("1.0.0"),
|
73 |
+
description="A Finnish News Corpus for Named Entity Recognition dataset",
|
74 |
+
),
|
75 |
+
]
|
76 |
+
|
77 |
+
def _info(self):
|
78 |
+
return datasets.DatasetInfo(
|
79 |
+
description=_DESCRIPTION,
|
80 |
+
features=datasets.Features(
|
81 |
+
{
|
82 |
+
"id": datasets.Value("string"),
|
83 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
84 |
+
"ner_tags": datasets.Sequence(
|
85 |
+
datasets.features.ClassLabel(
|
86 |
+
names=[
|
87 |
+
"O",
|
88 |
+
"B-DATE",
|
89 |
+
"B-EVENT",
|
90 |
+
"B-LOC",
|
91 |
+
"B-ORG",
|
92 |
+
"B-PER",
|
93 |
+
"B-PRO",
|
94 |
+
"I-DATE",
|
95 |
+
"I-EVENT",
|
96 |
+
"I-LOC",
|
97 |
+
"I-ORG",
|
98 |
+
"I-PER",
|
99 |
+
"I-PRO",
|
100 |
+
]
|
101 |
+
)
|
102 |
+
),
|
103 |
+
"nested_ner_tags": datasets.Sequence(
|
104 |
+
datasets.features.ClassLabel(
|
105 |
+
names=[
|
106 |
+
"O",
|
107 |
+
"B-DATE",
|
108 |
+
"B-EVENT",
|
109 |
+
"B-LOC",
|
110 |
+
"B-ORG",
|
111 |
+
"B-PER",
|
112 |
+
"B-PRO",
|
113 |
+
"I-DATE",
|
114 |
+
"I-EVENT",
|
115 |
+
"I-LOC",
|
116 |
+
"I-ORG",
|
117 |
+
"I-PER",
|
118 |
+
"I-PRO",
|
119 |
+
]
|
120 |
+
)
|
121 |
+
),
|
122 |
+
}
|
123 |
+
),
|
124 |
+
supervised_keys=None,
|
125 |
+
homepage="https://github.com/mpsilfve/finer-data",
|
126 |
+
citation=_CITATION,
|
127 |
+
)
|
128 |
+
|
129 |
+
def _split_generators(self, dl_manager):
|
130 |
+
"""Returns SplitGenerators."""
|
131 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
132 |
+
|
133 |
+
return [
|
134 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
135 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
136 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
137 |
+
datasets.SplitGenerator(
|
138 |
+
name=datasets.Split("test_wikipedia"), gen_kwargs={"filepath": downloaded_files["test_wikipedia"]}
|
139 |
+
),
|
140 |
+
]
|
141 |
+
|
142 |
+
def _generate_examples(self, filepath):
|
143 |
+
logging.info("โณ Generating ๐ซ๐ฎ examples from = %s", filepath)
|
144 |
+
with open(filepath, encoding="utf-8") as f:
|
145 |
+
data = csv.reader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
|
146 |
+
current_tokens = []
|
147 |
+
current_ner_tags = []
|
148 |
+
current_nested_ner_tags = []
|
149 |
+
sentence_counter = 0
|
150 |
+
for row in data:
|
151 |
+
if row and "" not in row:
|
152 |
+
token, label, nested_label = row[:3]
|
153 |
+
current_tokens.append(token)
|
154 |
+
current_ner_tags.append(label)
|
155 |
+
current_nested_ner_tags.append(nested_label)
|
156 |
+
else:
|
157 |
+
# New sentence
|
158 |
+
if not current_tokens:
|
159 |
+
# Consecutive empty lines will cause empty sentences
|
160 |
+
continue
|
161 |
+
assert len(current_tokens) == len(current_ner_tags), "๐ between len of tokens & labels"
|
162 |
+
assert len(current_ner_tags) == len(
|
163 |
+
current_nested_ner_tags
|
164 |
+
), "๐ between len of labels & nested labels"
|
165 |
+
sentence = (
|
166 |
+
sentence_counter,
|
167 |
+
{
|
168 |
+
"id": str(sentence_counter),
|
169 |
+
"tokens": current_tokens,
|
170 |
+
"ner_tags": current_ner_tags,
|
171 |
+
"nested_ner_tags": current_nested_ner_tags,
|
172 |
+
},
|
173 |
+
)
|
174 |
+
sentence_counter += 1
|
175 |
+
current_tokens = []
|
176 |
+
current_ner_tags = []
|
177 |
+
current_nested_ner_tags = []
|
178 |
+
yield sentence
|
179 |
+
# Don't forget last sentence in dataset ๐ง
|
180 |
+
if current_tokens:
|
181 |
+
yield sentence_counter, {
|
182 |
+
"id": str(sentence_counter),
|
183 |
+
"tokens": current_tokens,
|
184 |
+
"ner_tags": current_ner_tags,
|
185 |
+
"nested_ner_tags": current_nested_ner_tags,
|
186 |
+
}
|