Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
Faroese
Size:
1K<n<10K
License:
Added data
Browse files- README.md +3 -0
- sosialurin-faroese-ner.py +131 -0
- sosialurin.faroese.ner.train.txt +0 -0
README.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: cc-by-4.0
|
3 |
+
---
|
sosialurin-faroese-ner.py
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 HuggingFace Datasets Authors.
|
3 |
+
# Modified by Vésteinn Snæbjarnarson 2021
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
|
17 |
+
|
18 |
+
# Lint as: python3
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
LABELS = [
|
26 |
+
]
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
import datasets
|
31 |
+
|
32 |
+
|
33 |
+
logger = datasets.logging.get_logger(__name__)
|
34 |
+
|
35 |
+
|
36 |
+
_CITATION = """\
|
37 |
+
@misc{sosialurin-ner,
|
38 |
+
title = {},
|
39 |
+
author = {},
|
40 |
+
url = {},
|
41 |
+
year = {2022} }
|
42 |
+
"""
|
43 |
+
|
44 |
+
_DESCRIPTION = """\
|
45 |
+
The corpus that has been created consists of ca. 100.000 words of text from the [Faroese] newspaper Sosialurin. Each word is tagged with named entity information
|
46 |
+
"""
|
47 |
+
|
48 |
+
_URL = "https://huggingface.co/datasets/vesteinn/sosialurin-faroese-ner/raw/main/"
|
49 |
+
_TRAINING_FILE = "sosialurin.faroese.ner.train.txt"
|
50 |
+
|
51 |
+
|
52 |
+
class SosialurinNERConfig(datasets.BuilderConfig):
|
53 |
+
"""BuilderConfig for sosialurin-faroese-ner"""
|
54 |
+
|
55 |
+
def __init__(self, **kwargs):
|
56 |
+
"""BuilderConfig for sosialurin-faroese-ner.
|
57 |
+
Args:
|
58 |
+
**kwargs: keyword arguments forwarded to super.
|
59 |
+
"""
|
60 |
+
super(SosialurinNERConfig, self).__init__(**kwargs)
|
61 |
+
|
62 |
+
|
63 |
+
class SosialurinNER(datasets.GeneratorBasedBuilder):
|
64 |
+
"""sosialurin-faroese-ner dataset."""
|
65 |
+
|
66 |
+
BUILDER_CONFIGS = [
|
67 |
+
SosialurinNERConfig(name="sosialurin-faroese-ner", version=datasets.Version("0.1.0"), description="sosialurin-faroese-ner dataset"),
|
68 |
+
]
|
69 |
+
|
70 |
+
def _info(self):
|
71 |
+
return datasets.DatasetInfo(
|
72 |
+
description=_DESCRIPTION,
|
73 |
+
features=datasets.Features(
|
74 |
+
{
|
75 |
+
"id": datasets.Value("string"),
|
76 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
77 |
+
"ner_tags": datasets.Sequence(
|
78 |
+
datasets.features.ClassLabel(
|
79 |
+
names=LABELS
|
80 |
+
)
|
81 |
+
),
|
82 |
+
}
|
83 |
+
),
|
84 |
+
supervised_keys=None,
|
85 |
+
homepage="",
|
86 |
+
citation=_CITATION,
|
87 |
+
)
|
88 |
+
|
89 |
+
def _split_generators(self, dl_manager):
|
90 |
+
"""Returns SplitGenerators."""
|
91 |
+
urls_to_download = {
|
92 |
+
"train": f"{_URL}{_TRAINING_FILE}",
|
93 |
+
}
|
94 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
95 |
+
|
96 |
+
return [
|
97 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
98 |
+
]
|
99 |
+
|
100 |
+
def _generate_examples(self, filepath):
|
101 |
+
logger.info("⏳ Generating examples from = %s", filepath)
|
102 |
+
with open(filepath, encoding="utf-8") as f:
|
103 |
+
guid = 0
|
104 |
+
tokens = []
|
105 |
+
ner_tags = []
|
106 |
+
for line in f:
|
107 |
+
if line.startswith("-DOCSTART-") or line == "" or line == "\n":
|
108 |
+
if tokens:
|
109 |
+
yield guid, {
|
110 |
+
"id": str(guid),
|
111 |
+
"tokens": tokens,
|
112 |
+
"ner_tags": ner_tags,
|
113 |
+
}
|
114 |
+
guid += 1
|
115 |
+
tokens = []
|
116 |
+
ner_tags = []
|
117 |
+
else:
|
118 |
+
# tokens are tab separated
|
119 |
+
splits = line.split("\t")
|
120 |
+
tokens.append(splits[0])
|
121 |
+
try:
|
122 |
+
ner_tags.append(splits[1].rstrip())
|
123 |
+
except:
|
124 |
+
print(splits)
|
125 |
+
raise
|
126 |
+
# last example
|
127 |
+
yield guid, {
|
128 |
+
"id": str(guid),
|
129 |
+
"tokens": tokens,
|
130 |
+
"ner_tags": ner_tags,
|
131 |
+
}
|
sosialurin.faroese.ner.train.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|