Datasets:
Tasks:
Token Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
named-entity-recognition
Languages:
Romanian
Size:
10K - 100K
ArXiv:
License:
Commit
•
e8237fb
1
Parent(s):
8e4f9bd
Delete loading script
Browse files
ronec.py
DELETED
@@ -1,161 +0,0 @@
|
|
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 |
-
import json
|
17 |
-
|
18 |
-
import datasets
|
19 |
-
|
20 |
-
|
21 |
-
logger = datasets.logging.get_logger(__name__)
|
22 |
-
|
23 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
24 |
-
_CITATION = """\
|
25 |
-
@article{dumitrescu2019introducing,
|
26 |
-
title={Introducing RONEC--the Romanian Named Entity Corpus},
|
27 |
-
author={Dumitrescu, Stefan Daniel and Avram, Andrei-Marius},
|
28 |
-
journal={arXiv preprint arXiv:1909.01247},
|
29 |
-
year={2019}
|
30 |
-
}
|
31 |
-
"""
|
32 |
-
|
33 |
-
# You can copy an official description
|
34 |
-
_DESCRIPTION = """\
|
35 |
-
RONEC - the Romanian Named Entity Corpus, at version 2.0, holds 12330 sentences with over 0.5M tokens, annotated with 15 classes, to a total of 80.283 distinctly annotated entities. It is used for named entity recognition and represents the largest Romanian NER corpus to date.
|
36 |
-
"""
|
37 |
-
|
38 |
-
_HOMEPAGE = "https://github.com/dumitrescustefan/ronec"
|
39 |
-
|
40 |
-
_LICENSE = "MIT License"
|
41 |
-
|
42 |
-
# The HuggingFace dataset library don't host the datasets but only point to the original files
|
43 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
44 |
-
_URL = "https://raw.githubusercontent.com/dumitrescustefan/ronec/master/data/"
|
45 |
-
_TRAINING_FILE = "train.json"
|
46 |
-
_DEV_FILE = "valid.json"
|
47 |
-
_TEST_FILE = "test.json"
|
48 |
-
|
49 |
-
|
50 |
-
class RONECConfig(datasets.BuilderConfig):
|
51 |
-
"""BuilderConfig for RONEC dataset"""
|
52 |
-
|
53 |
-
def __init__(self, **kwargs):
|
54 |
-
super(RONECConfig, self).__init__(**kwargs)
|
55 |
-
|
56 |
-
|
57 |
-
class RONEC(datasets.GeneratorBasedBuilder):
|
58 |
-
"""RONEC dataset"""
|
59 |
-
|
60 |
-
VERSION = datasets.Version("2.0.0")
|
61 |
-
BUILDER_CONFIGS = [
|
62 |
-
RONECConfig(name="ronec", version=VERSION, description="RONEC dataset"),
|
63 |
-
]
|
64 |
-
|
65 |
-
def _info(self):
|
66 |
-
features = datasets.Features(
|
67 |
-
{
|
68 |
-
"id": datasets.Value("int32"),
|
69 |
-
"tokens": datasets.Sequence(datasets.Value("string")),
|
70 |
-
"ner_ids": datasets.Sequence(datasets.Value("int32")),
|
71 |
-
"space_after": datasets.Sequence(datasets.Value("bool")),
|
72 |
-
"ner_tags": datasets.Sequence(
|
73 |
-
datasets.features.ClassLabel(
|
74 |
-
names=[
|
75 |
-
"O",
|
76 |
-
"B-PERSON",
|
77 |
-
"I-PERSON",
|
78 |
-
"B-ORG",
|
79 |
-
"I-ORG",
|
80 |
-
"B-GPE",
|
81 |
-
"I-GPE",
|
82 |
-
"B-LOC",
|
83 |
-
"I-LOC",
|
84 |
-
"B-NAT_REL_POL",
|
85 |
-
"I-NAT_REL_POL",
|
86 |
-
"B-EVENT",
|
87 |
-
"I-EVENT",
|
88 |
-
"B-LANGUAGE",
|
89 |
-
"I-LANGUAGE",
|
90 |
-
"B-WORK_OF_ART",
|
91 |
-
"I-WORK_OF_ART",
|
92 |
-
"B-DATETIME",
|
93 |
-
"I-DATETIME",
|
94 |
-
"B-PERIOD",
|
95 |
-
"I-PERIOD",
|
96 |
-
"B-MONEY",
|
97 |
-
"I-MONEY",
|
98 |
-
"B-QUANTITY",
|
99 |
-
"I-QUANTITY",
|
100 |
-
"B-NUMERIC",
|
101 |
-
"I-NUMERIC",
|
102 |
-
"B-ORDINAL",
|
103 |
-
"I-ORDINAL",
|
104 |
-
"B-FACILITY",
|
105 |
-
"I-FACILITY",
|
106 |
-
]
|
107 |
-
)
|
108 |
-
),
|
109 |
-
}
|
110 |
-
)
|
111 |
-
|
112 |
-
return datasets.DatasetInfo(
|
113 |
-
# This is the description that will appear on the datasets page.
|
114 |
-
description=_DESCRIPTION,
|
115 |
-
# This defines the different columns of the dataset and their types
|
116 |
-
features=features, # Here we define them above because they are different between the two configurations
|
117 |
-
# If there's a common (input, target) tuple from the features,
|
118 |
-
# specify them here. They'll be used if as_supervised=True in
|
119 |
-
# builder.as_dataset.
|
120 |
-
supervised_keys=None,
|
121 |
-
# Homepage of the dataset for documentation
|
122 |
-
homepage=_HOMEPAGE,
|
123 |
-
# License for the dataset if available
|
124 |
-
license=_LICENSE,
|
125 |
-
# Citation for the dataset
|
126 |
-
citation=_CITATION,
|
127 |
-
)
|
128 |
-
|
129 |
-
def _split_generators(self, dl_manager):
|
130 |
-
"""Returns SplitGenerators."""
|
131 |
-
|
132 |
-
urls_to_download = {"train": _URL + _TRAINING_FILE, "dev": _URL + _DEV_FILE, "test": _URL + _TEST_FILE}
|
133 |
-
|
134 |
-
downloaded_files = dl_manager.download(urls_to_download)
|
135 |
-
|
136 |
-
return [
|
137 |
-
datasets.SplitGenerator(
|
138 |
-
name=datasets.Split.TRAIN,
|
139 |
-
# These kwargs will be passed to _generate_examples
|
140 |
-
gen_kwargs={"filepath": downloaded_files["train"]},
|
141 |
-
),
|
142 |
-
datasets.SplitGenerator(
|
143 |
-
name=datasets.Split.VALIDATION,
|
144 |
-
# These kwargs will be passed to _generate_examples
|
145 |
-
gen_kwargs={"filepath": downloaded_files["dev"]},
|
146 |
-
),
|
147 |
-
datasets.SplitGenerator(
|
148 |
-
name=datasets.Split.TEST,
|
149 |
-
# These kwargs will be passed to _generate_examples
|
150 |
-
gen_kwargs={"filepath": downloaded_files["test"]},
|
151 |
-
),
|
152 |
-
]
|
153 |
-
|
154 |
-
def _generate_examples(self, filepath):
|
155 |
-
"""Yields examples."""
|
156 |
-
|
157 |
-
logger.info("⏳ Generating examples from = %s", filepath)
|
158 |
-
with open(filepath, "r", encoding="utf-8") as f:
|
159 |
-
data = json.load(f)
|
160 |
-
for instance in data:
|
161 |
-
yield instance["id"], instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|