Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
Turkish
Size:
100K<n<1M
License:
Commit
·
a006ebf
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 +141 -0
- dataset_infos.json +1 -0
- dummy/0.0.0/dummy_data.zip +3 -0
- turkish_shrinked_ner.py +229 -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,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- machine-generated
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
languages:
|
7 |
+
- tr
|
8 |
+
licenses:
|
9 |
+
- cc-by-4-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 100K<n<1M
|
14 |
+
source_datasets:
|
15 |
+
- extended|other-turkish_ner
|
16 |
+
task_categories:
|
17 |
+
- structure-prediction
|
18 |
+
task_ids:
|
19 |
+
- named-entity-recognition
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for turkish_shrinked_ner
|
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:** https://www.kaggle.com/behcetsenturk/shrinked-twnertc-turkish-ner-data-by-kuzgunlar
|
50 |
+
- **Repository:** [Needs More Information]
|
51 |
+
- **Paper:** [Needs More Information]
|
52 |
+
- **Leaderboard:** [Needs More Information]
|
53 |
+
- **Point of Contact:** https://www.kaggle.com/behcetsenturk
|
54 |
+
|
55 |
+
### Dataset Summary
|
56 |
+
|
57 |
+
Shrinked processed version (48 entity type) of the turkish_ner.
|
58 |
+
|
59 |
+
Original turkish_ner dataset: Automatically annotated Turkish corpus for named entity recognition and text categorization using large-scale gazetteers. The constructed gazetteers contains approximately 300K entities with thousands of fine-grained entity types under 25 different domains.
|
60 |
+
|
61 |
+
Shrinked entity types are: academic, academic_person, aircraft, album_person, anatomy, animal, architect_person, capital, chemical, clothes, country, culture, currency, date, food, genre, government, government_person, language, location, material, measure, medical, military, military_person, nation, newspaper, organization, organization_person, person, production_art_music, production_art_music_person, quantity, religion, science, shape, ship, software, space, space_person, sport, sport_name, sport_person, structure, subject, tech, train, vehicle
|
62 |
+
|
63 |
+
### Supported Tasks and Leaderboards
|
64 |
+
|
65 |
+
[Needs More Information]
|
66 |
+
|
67 |
+
### Languages
|
68 |
+
|
69 |
+
Turkish
|
70 |
+
|
71 |
+
## Dataset Structure
|
72 |
+
|
73 |
+
### Data Instances
|
74 |
+
|
75 |
+
[Needs More Information]
|
76 |
+
|
77 |
+
### Data Fields
|
78 |
+
|
79 |
+
[Needs More Information]
|
80 |
+
|
81 |
+
### Data Splits
|
82 |
+
|
83 |
+
There's only the training set.
|
84 |
+
|
85 |
+
## Dataset Creation
|
86 |
+
|
87 |
+
### Curation Rationale
|
88 |
+
|
89 |
+
[Needs More Information]
|
90 |
+
|
91 |
+
### Source Data
|
92 |
+
|
93 |
+
#### Initial Data Collection and Normalization
|
94 |
+
|
95 |
+
[Needs More Information]
|
96 |
+
|
97 |
+
#### Who are the source language producers?
|
98 |
+
|
99 |
+
[Needs More Information]
|
100 |
+
|
101 |
+
### Annotations
|
102 |
+
|
103 |
+
#### Annotation process
|
104 |
+
|
105 |
+
[Needs More Information]
|
106 |
+
|
107 |
+
#### Who are the annotators?
|
108 |
+
|
109 |
+
[Needs More Information]
|
110 |
+
|
111 |
+
### Personal and Sensitive Information
|
112 |
+
|
113 |
+
[Needs More Information]
|
114 |
+
|
115 |
+
## Considerations for Using the Data
|
116 |
+
|
117 |
+
### Social Impact of Dataset
|
118 |
+
|
119 |
+
[Needs More Information]
|
120 |
+
|
121 |
+
### Discussion of Biases
|
122 |
+
|
123 |
+
[Needs More Information]
|
124 |
+
|
125 |
+
### Other Known Limitations
|
126 |
+
|
127 |
+
[Needs More Information]
|
128 |
+
|
129 |
+
## Additional Information
|
130 |
+
|
131 |
+
### Dataset Curators
|
132 |
+
|
133 |
+
Behcet Senturk
|
134 |
+
|
135 |
+
### Licensing Information
|
136 |
+
|
137 |
+
Creative Commons Attribution 4.0 International
|
138 |
+
|
139 |
+
### Citation Information
|
140 |
+
|
141 |
+
[Needs More Information]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "Shrinked version (48 entity type) of the turkish_ner.\n\nOriginal turkish_ner dataset: Automatically annotated Turkish corpus for named entity recognition and text categorization using large-scale gazetteers. The constructed gazetteers contains approximately 300K entities with thousands of fine-grained entity types under 25 different domains.\n\nShrinked entity types are: academic, academic_person, aircraft, album_person, anatomy, animal, architect_person, capital, chemical, clothes, country, culture, currency, date, food, genre, government, government_person, language, location, material, measure, medical, military, military_person, nation, newspaper, organization, organization_person, person, production_art_music, production_art_music_person, quantity, religion, science, shape, ship, software, space, space_person, sport, sport_name, sport_person, structure, subject, tech, train, vehicle\n", "citation": "", "homepage": "https://www.kaggle.com/behcetsenturk/shrinked-twnertc-turkish-ner-data-by-kuzgunlar", "license": "Attribution 4.0 International (CC BY 4.0)", "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": 97, "names": ["O", "B-academic", "I-academic", "B-academic_person", "I-academic_person", "B-aircraft", "I-aircraft", "B-album_person", "I-album_person", "B-anatomy", "I-anatomy", "B-animal", "I-animal", "B-architect_person", "I-architect_person", "B-capital", "I-capital", "B-chemical", "I-chemical", "B-clothes", "I-clothes", "B-country", "I-country", "B-culture", "I-culture", "B-currency", "I-currency", "B-date", "I-date", "B-food", "I-food", "B-genre", "I-genre", "B-government", "I-government", "B-government_person", "I-government_person", "B-language", "I-language", "B-location", "I-location", "B-material", "I-material", "B-measure", "I-measure", "B-medical", "I-medical", "B-military", "I-military", "B-military_person", "I-military_person", "B-nation", "I-nation", "B-newspaper", "I-newspaper", "B-organization", "I-organization", "B-organization_person", "I-organization_person", "B-person", "I-person", "B-production_art_music", "I-production_art_music", "B-production_art_music_person", "I-production_art_music_person", "B-quantity", "I-quantity", "B-religion", "I-religion", "B-science", "I-science", "B-shape", "I-shape", "B-ship", "I-ship", "B-software", "I-software", "B-space", "I-space", "B-space_person", "I-space_person", "B-sport", "I-sport", "B-sport_name", "I-sport_name", "B-sport_person", "I-sport_person", "B-structure", "I-structure", "B-subject", "I-subject", "B-tech", "I-tech", "B-train", "I-train", "B-vehicle", "I-vehicle"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "turkish_shrinked_ner", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 200728389, "num_examples": 614515, "dataset_name": "turkish_shrinked_ner"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 200728389, "size_in_bytes": 200728389}}
|
dummy/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66afcc7a8328814a5fe5beb583bba3cc384f0897b7bf9ffa7ff37b927a148859
|
3 |
+
size 30664
|
turkish_shrinked_ner.py
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
""" Shrinked Turkish NER """
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import logging
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
"""
|
27 |
+
|
28 |
+
_DESCRIPTION = """\
|
29 |
+
Shrinked version (48 entity type) of the turkish_ner.
|
30 |
+
|
31 |
+
Original turkish_ner dataset: Automatically annotated Turkish corpus for named entity recognition and text categorization using large-scale gazetteers. The constructed gazetteers contains approximately 300K entities with thousands of fine-grained entity types under 25 different domains.
|
32 |
+
|
33 |
+
Shrinked entity types are: academic, academic_person, aircraft, album_person, anatomy, animal, architect_person, capital, chemical, clothes, country, culture, currency, date, food, genre, government, government_person, language, location, material, measure, medical, military, military_person, nation, newspaper, organization, organization_person, person, production_art_music, production_art_music_person, quantity, religion, science, shape, ship, software, space, space_person, sport, sport_name, sport_person, structure, subject, tech, train, vehicle
|
34 |
+
"""
|
35 |
+
|
36 |
+
_HOMEPAGE = "https://www.kaggle.com/behcetsenturk/shrinked-twnertc-turkish-ner-data-by-kuzgunlar"
|
37 |
+
|
38 |
+
_LICENSE = "Attribution 4.0 International (CC BY 4.0)"
|
39 |
+
|
40 |
+
_FILENAME = "train.txt"
|
41 |
+
|
42 |
+
|
43 |
+
class TurkishShrinkedNER(datasets.GeneratorBasedBuilder):
|
44 |
+
@property
|
45 |
+
def manual_download_instructions(self):
|
46 |
+
return """\
|
47 |
+
You need to go to https://www.kaggle.com/behcetsenturk/shrinked-twnertc-turkish-ner-data-by-kuzgunlar,
|
48 |
+
and manually download the turkish_shrinked_ner. Once it is completed,
|
49 |
+
a file named archive.zip will be appeared in your Downloads folder
|
50 |
+
or whichever folder your browser chooses to save files to. You then have
|
51 |
+
to unzip the file and move train.txt under <path/to/folder>.
|
52 |
+
The <path/to/folder> can e.g. be "~/manual_data".
|
53 |
+
turkish_shrinked_ner can then be loaded using the following command `datasets.load_dataset("turkish_shrinked_ner", data_dir="<path/to/folder>")`.
|
54 |
+
"""
|
55 |
+
|
56 |
+
def _info(self):
|
57 |
+
return datasets.DatasetInfo(
|
58 |
+
description=_DESCRIPTION,
|
59 |
+
features=datasets.Features(
|
60 |
+
{
|
61 |
+
"id": datasets.Value("string"),
|
62 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
63 |
+
"ner_tags": datasets.Sequence(
|
64 |
+
datasets.features.ClassLabel(
|
65 |
+
names=[
|
66 |
+
"O",
|
67 |
+
"B-academic",
|
68 |
+
"I-academic",
|
69 |
+
"B-academic_person",
|
70 |
+
"I-academic_person",
|
71 |
+
"B-aircraft",
|
72 |
+
"I-aircraft",
|
73 |
+
"B-album_person",
|
74 |
+
"I-album_person",
|
75 |
+
"B-anatomy",
|
76 |
+
"I-anatomy",
|
77 |
+
"B-animal",
|
78 |
+
"I-animal",
|
79 |
+
"B-architect_person",
|
80 |
+
"I-architect_person",
|
81 |
+
"B-capital",
|
82 |
+
"I-capital",
|
83 |
+
"B-chemical",
|
84 |
+
"I-chemical",
|
85 |
+
"B-clothes",
|
86 |
+
"I-clothes",
|
87 |
+
"B-country",
|
88 |
+
"I-country",
|
89 |
+
"B-culture",
|
90 |
+
"I-culture",
|
91 |
+
"B-currency",
|
92 |
+
"I-currency",
|
93 |
+
"B-date",
|
94 |
+
"I-date",
|
95 |
+
"B-food",
|
96 |
+
"I-food",
|
97 |
+
"B-genre",
|
98 |
+
"I-genre",
|
99 |
+
"B-government",
|
100 |
+
"I-government",
|
101 |
+
"B-government_person",
|
102 |
+
"I-government_person",
|
103 |
+
"B-language",
|
104 |
+
"I-language",
|
105 |
+
"B-location",
|
106 |
+
"I-location",
|
107 |
+
"B-material",
|
108 |
+
"I-material",
|
109 |
+
"B-measure",
|
110 |
+
"I-measure",
|
111 |
+
"B-medical",
|
112 |
+
"I-medical",
|
113 |
+
"B-military",
|
114 |
+
"I-military",
|
115 |
+
"B-military_person",
|
116 |
+
"I-military_person",
|
117 |
+
"B-nation",
|
118 |
+
"I-nation",
|
119 |
+
"B-newspaper",
|
120 |
+
"I-newspaper",
|
121 |
+
"B-organization",
|
122 |
+
"I-organization",
|
123 |
+
"B-organization_person",
|
124 |
+
"I-organization_person",
|
125 |
+
"B-person",
|
126 |
+
"I-person",
|
127 |
+
"B-production_art_music",
|
128 |
+
"I-production_art_music",
|
129 |
+
"B-production_art_music_person",
|
130 |
+
"I-production_art_music_person",
|
131 |
+
"B-quantity",
|
132 |
+
"I-quantity",
|
133 |
+
"B-religion",
|
134 |
+
"I-religion",
|
135 |
+
"B-science",
|
136 |
+
"I-science",
|
137 |
+
"B-shape",
|
138 |
+
"I-shape",
|
139 |
+
"B-ship",
|
140 |
+
"I-ship",
|
141 |
+
"B-software",
|
142 |
+
"I-software",
|
143 |
+
"B-space",
|
144 |
+
"I-space",
|
145 |
+
"B-space_person",
|
146 |
+
"I-space_person",
|
147 |
+
"B-sport",
|
148 |
+
"I-sport",
|
149 |
+
"B-sport_name",
|
150 |
+
"I-sport_name",
|
151 |
+
"B-sport_person",
|
152 |
+
"I-sport_person",
|
153 |
+
"B-structure",
|
154 |
+
"I-structure",
|
155 |
+
"B-subject",
|
156 |
+
"I-subject",
|
157 |
+
"B-tech",
|
158 |
+
"I-tech",
|
159 |
+
"B-train",
|
160 |
+
"I-train",
|
161 |
+
"B-vehicle",
|
162 |
+
"I-vehicle",
|
163 |
+
]
|
164 |
+
)
|
165 |
+
),
|
166 |
+
}
|
167 |
+
),
|
168 |
+
supervised_keys=None,
|
169 |
+
# Homepage of the dataset for documentation
|
170 |
+
homepage=_HOMEPAGE,
|
171 |
+
# License for the dataset if available
|
172 |
+
license=_LICENSE,
|
173 |
+
# Citation for the dataset
|
174 |
+
citation=_CITATION,
|
175 |
+
)
|
176 |
+
|
177 |
+
def _split_generators(self, dl_manager):
|
178 |
+
"""Returns SplitGenerators."""
|
179 |
+
path_to_manual_file = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
|
180 |
+
if not os.path.exists(path_to_manual_file):
|
181 |
+
raise FileNotFoundError(
|
182 |
+
"{} does not exist. Make sure you insert a manual dir via `datasets.load_dataset('turkish_shrinked_ner', data_dir=...)` that includes file name {}. Manual download instructions: {}".format(
|
183 |
+
path_to_manual_file,
|
184 |
+
_FILENAME,
|
185 |
+
self.manual_download_instructions,
|
186 |
+
)
|
187 |
+
)
|
188 |
+
return [
|
189 |
+
datasets.SplitGenerator(
|
190 |
+
name=datasets.Split.TRAIN,
|
191 |
+
# These kwargs will be passed to _generate_examples
|
192 |
+
gen_kwargs={
|
193 |
+
"filepath": os.path.join(path_to_manual_file, "train.txt"),
|
194 |
+
"split": "train",
|
195 |
+
},
|
196 |
+
),
|
197 |
+
]
|
198 |
+
|
199 |
+
def _generate_examples(self, filepath, split):
|
200 |
+
""" Yields examples. """
|
201 |
+
logging.info("⏳ Generating examples from = %s", filepath)
|
202 |
+
|
203 |
+
with open(filepath, encoding="utf-8") as f:
|
204 |
+
id_ = 0
|
205 |
+
tokens = []
|
206 |
+
ner_tags = []
|
207 |
+
for row in f:
|
208 |
+
if row == "":
|
209 |
+
continue
|
210 |
+
elif row == "\n":
|
211 |
+
yield id_, {
|
212 |
+
"id": str(id_),
|
213 |
+
"tokens": tokens,
|
214 |
+
"ner_tags": ner_tags,
|
215 |
+
}
|
216 |
+
tokens = []
|
217 |
+
ner_tags = []
|
218 |
+
id_ += 1
|
219 |
+
else:
|
220 |
+
token, tag = row.split(" ")
|
221 |
+
tokens.append(token)
|
222 |
+
ner_tags.append(tag)
|
223 |
+
|
224 |
+
if len(tokens) > 0:
|
225 |
+
yield id_, {
|
226 |
+
"id": str(id_),
|
227 |
+
"tokens": tokens,
|
228 |
+
"ner_tags": ner_tags,
|
229 |
+
}
|