Datasets:
Tasks:
Other
Modalities:
Text
Sub-tasks:
named-entity-recognition
Languages:
Polish
Size:
10K - 100K
Tags:
structure-prediction
License:
Albert Sawczyn
commited on
Commit
•
b194823
1
Parent(s):
5b08b7f
add dataset
Browse files- .gitattributes +1 -0
- README.md +402 -0
- data/kpwr-ner-n82-test.iob +0 -0
- data/kpwr-ner-n82-train-tune.iob +0 -0
- kpwr-ner.py +266 -0
.gitattributes
CHANGED
@@ -14,3 +14,4 @@
|
|
14 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
|
|
|
14 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.iob filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,402 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- pl
|
8 |
+
licenses:
|
9 |
+
- cc-by-3.0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
pretty_name: ''
|
13 |
+
size_categories:
|
14 |
+
- 18K
|
15 |
+
- 10K<n<100K
|
16 |
+
source_datasets:
|
17 |
+
- original
|
18 |
+
task_categories:
|
19 |
+
- structure-prediction
|
20 |
+
task_ids:
|
21 |
+
- named-entity-recognition
|
22 |
+
---
|
23 |
+
|
24 |
+
# KPWR-NER
|
25 |
+
|
26 |
+
## Description
|
27 |
+
|
28 |
+
KPWR-NER is a part the Polish Corpus of Wrocław University of Technology (*Korpus Języka Polskiego Politechniki Wrocławskiej*). Its objective is named entity recognition for fine-grained categories of entities. It is the ‘n82’ version of the KPWr, which means that number of classes is restricted to 82 (originally 120). During corpus creation, texts were annotated by humans from various sources, covering many domains and genres.
|
29 |
+
|
30 |
+
## Tasks (input, output and metrics)
|
31 |
+
|
32 |
+
Named entity recognition (NER) - tagging entities in text with their corresponding type.
|
33 |
+
|
34 |
+
Input ('*tokens'* column): sequence of tokens
|
35 |
+
|
36 |
+
Output ('*ner'* column): sequence of predicted tokens’ classes in BIO notation (82 possible classes, described in detail in the annotation guidelines)
|
37 |
+
|
38 |
+
*example:*
|
39 |
+
|
40 |
+
[*‘Roboty’, ‘mają’, ‘kilkanaście’, ‘lat’, ‘i’, ‘pochodzą’, ‘z’, ‘USA’, ‘,’, ‘Wysokie’, ‘napięcie’, ‘jest’, ‘dużo’, ‘młodsze’, ‘,’, ‘powstało’, ‘w’, ‘Niemczech’, ‘.’*] → [*‘B-nam_pro_title’, ‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘B-nam_loc_gpe_country’, ‘O’, ‘B-nam_pro_title’, ‘I-nam_pro_title’, ‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘B-nam_loc_gpe_country’, ‘O’*]
|
41 |
+
|
42 |
+
Measurements:
|
43 |
+
|
44 |
+
## Data splits
|
45 |
+
|
46 |
+
|
47 |
+
| Subset | Cardinality (sentences) |
|
48 |
+
|--------|------------------------:|
|
49 |
+
| train | 13959 |
|
50 |
+
| test | 4323 |
|
51 |
+
|
52 |
+
## Class distribution in train
|
53 |
+
|
54 |
+
| Class | Fraction of tokens |
|
55 |
+
|:----------------------------|---------------------:|
|
56 |
+
| O | 0.898080 |
|
57 |
+
| B-nam_liv_person | 0.012769 |
|
58 |
+
| I-nam_liv_person | 0.008246 |
|
59 |
+
| I-nam_org_institution | 0.006448 |
|
60 |
+
| B-nam_loc_gpe_city | 0.005886 |
|
61 |
+
| B-nam_loc_gpe_country | 0.004351 |
|
62 |
+
| I-nam_org_organization | 0.003728 |
|
63 |
+
| B-nam_org_institution | 0.003434 |
|
64 |
+
| I-nam_pro_title_document | 0.003206 |
|
65 |
+
| B-nam_org_organization | 0.002592 |
|
66 |
+
| B-nam_org_group_team | 0.002035 |
|
67 |
+
| B-nam_adj_country | 0.001987 |
|
68 |
+
| I-nam_org_group_team | 0.001851 |
|
69 |
+
| I-nam_pro_title | 0.001715 |
|
70 |
+
| I-nam_eve_human | 0.001557 |
|
71 |
+
| B-nam_org_company | 0.001421 |
|
72 |
+
| I-nam_org_company | 0.001316 |
|
73 |
+
| B-nam_pro_media_periodic | 0.001312 |
|
74 |
+
| I-nam_fac_goe | 0.001285 |
|
75 |
+
| I-nam_pro_media_periodic | 0.001254 |
|
76 |
+
| B-nam_fac_road | 0.001162 |
|
77 |
+
| B-nam_liv_god | 0.001127 |
|
78 |
+
| I-nam_eve_human_sport | 0.001057 |
|
79 |
+
| B-nam_org_nation | 0.001013 |
|
80 |
+
| B-nam_oth_tech | 0.001004 |
|
81 |
+
| B-nam_pro_media_web | 0.000996 |
|
82 |
+
| B-nam_fac_goe | 0.000930 |
|
83 |
+
| B-nam_eve_human | 0.000917 |
|
84 |
+
| B-nam_pro_title | 0.000908 |
|
85 |
+
| B-nam_pro_brand | 0.000899 |
|
86 |
+
| I-nam_pro_model_car | 0.000877 |
|
87 |
+
| I-nam_pro_brand | 0.000868 |
|
88 |
+
| I-nam_loc_gpe_city | 0.000847 |
|
89 |
+
| B-nam_org_political_party | 0.000737 |
|
90 |
+
| I-nam_loc_gpe_country | 0.000715 |
|
91 |
+
| B-nam_loc_gpe_admin1 | 0.000711 |
|
92 |
+
| I-nam_pro_title_treaty | 0.000697 |
|
93 |
+
| B-nam_eve_human_sport | 0.000684 |
|
94 |
+
| I-nam_org_political_party | 0.000680 |
|
95 |
+
| B-nam_pro_software | 0.000636 |
|
96 |
+
| I-nam_fac_road | 0.000623 |
|
97 |
+
| B-nam_adj | 0.000561 |
|
98 |
+
| B-nam_loc_gpe_admin3 | 0.000518 |
|
99 |
+
| B-nam_pro_model_car | 0.000509 |
|
100 |
+
| B-nam_loc_hydronym_river | 0.000491 |
|
101 |
+
| B-nam_oth | 0.000452 |
|
102 |
+
| B-nam_pro_title_document | 0.000430 |
|
103 |
+
| B-nam_loc_astronomical | 0.000425 |
|
104 |
+
| B-nam_oth_currency | 0.000421 |
|
105 |
+
| B-nam_adj_city | 0.000390 |
|
106 |
+
| I-nam_eve | 0.000373 |
|
107 |
+
| I-nam_org_group_band | 0.000364 |
|
108 |
+
| B-nam_org_group_band | 0.000342 |
|
109 |
+
| I-nam_pro_media_web | 0.000329 |
|
110 |
+
| I-nam_pro_title_book | 0.000329 |
|
111 |
+
| B-nam_loc_gpe_admin2 | 0.000329 |
|
112 |
+
| I-nam_pro_software | 0.000320 |
|
113 |
+
| I-nam_eve_human_cultural | 0.000298 |
|
114 |
+
| I-nam_oth_tech | 0.000294 |
|
115 |
+
| B-nam_loc_gpe_district | 0.000294 |
|
116 |
+
| I-nam_oth | 0.000285 |
|
117 |
+
| B-nam_loc_land_continent | 0.000268 |
|
118 |
+
| B-nam_loc_country_region | 0.000268 |
|
119 |
+
| B-nam_loc_land_mountain | 0.000241 |
|
120 |
+
| I-nam_pro_title_article | 0.000228 |
|
121 |
+
| B-nam_pro_title_book | 0.000224 |
|
122 |
+
| B-nam_loc_historical_region | 0.000219 |
|
123 |
+
| B-nam_loc | 0.000211 |
|
124 |
+
| B-nam_eve | 0.000211 |
|
125 |
+
| B-nam_org_group | 0.000193 |
|
126 |
+
| B-nam_loc_land_island | 0.000193 |
|
127 |
+
| I-nam_pro_title_tv | 0.000193 |
|
128 |
+
| I-nam_pro_title_album | 0.000189 |
|
129 |
+
| B-nam_pro_media_tv | 0.000184 |
|
130 |
+
| B-nam_liv_habitant | 0.000184 |
|
131 |
+
| B-nam_eve_human_cultural | 0.000184 |
|
132 |
+
| I-nam_pro_title_song | 0.000184 |
|
133 |
+
| I-nam_oth_license | 0.000180 |
|
134 |
+
| B-nam_pro_title_tv | 0.000180 |
|
135 |
+
| I-nam_oth_position | 0.000175 |
|
136 |
+
| I-nam_loc_country_region | 0.000171 |
|
137 |
+
| I-nam_loc_gpe_admin1 | 0.000171 |
|
138 |
+
| B-nam_oth_license | 0.000167 |
|
139 |
+
| B-nam_num_house | 0.000149 |
|
140 |
+
| B-nam_pro_title_treaty | 0.000145 |
|
141 |
+
| B-nam_fac_system | 0.000145 |
|
142 |
+
| I-nam_loc_gpe_admin3 | 0.000140 |
|
143 |
+
| B-nam_loc_gpe_subdivision | 0.000140 |
|
144 |
+
| I-nam_eve_human_holiday | 0.000136 |
|
145 |
+
| I-nam_org_group | 0.000136 |
|
146 |
+
| B-nam_loc_land_region | 0.000132 |
|
147 |
+
| I-nam_pro_award | 0.000132 |
|
148 |
+
| I-nam_loc_land_mountain | 0.000132 |
|
149 |
+
| I-nam_loc_astronomical | 0.000132 |
|
150 |
+
| B-nam_pro_title_album | 0.000127 |
|
151 |
+
| I-nam_pro_software_game | 0.000123 |
|
152 |
+
| B-nam_adj_person | 0.000118 |
|
153 |
+
| B-nam_fac_square | 0.000114 |
|
154 |
+
| I-nam_pro_media_radio | 0.000114 |
|
155 |
+
| B-nam_pro_award | 0.000110 |
|
156 |
+
| B-nam_eve_human_holiday | 0.000110 |
|
157 |
+
| I-nam_loc | 0.000101 |
|
158 |
+
| B-nam_pro_title_song | 0.000096 |
|
159 |
+
| I-nam_loc_gpe_subdivision | 0.000096 |
|
160 |
+
| B-nam_pro_media_radio | 0.000088 |
|
161 |
+
| I-nam_loc_gpe_district | 0.000088 |
|
162 |
+
| B-nam_pro_vehicle | 0.000088 |
|
163 |
+
| I-nam_loc_land_island | 0.000083 |
|
164 |
+
| I-nam_fac_park | 0.000083 |
|
165 |
+
| B-nam_oth_position | 0.000083 |
|
166 |
+
| B-nam_liv_animal | 0.000083 |
|
167 |
+
| I-nam_pro | 0.000083 |
|
168 |
+
| B-nam_pro | 0.000079 |
|
169 |
+
| I-nam_loc_historical_region | 0.000079 |
|
170 |
+
| I-nam_loc_land_region | 0.000075 |
|
171 |
+
| I-nam_liv_god | 0.000075 |
|
172 |
+
| I-nam_num_phone | 0.000075 |
|
173 |
+
| I-nam_fac_bridge | 0.000075 |
|
174 |
+
| I-nam_pro_media_tv | 0.000070 |
|
175 |
+
| B-nam_oth_www | 0.000070 |
|
176 |
+
| B-nam_num_phone | 0.000070 |
|
177 |
+
| B-nam_pro_title_article | 0.000066 |
|
178 |
+
| B-nam_oth_data_format | 0.000066 |
|
179 |
+
| B-nam_fac_bridge | 0.000061 |
|
180 |
+
| B-nam_liv_character | 0.000057 |
|
181 |
+
| I-nam_org_organization_sub | 0.000053 |
|
182 |
+
| B-nam_pro_software_game | 0.000053 |
|
183 |
+
| B-nam_loc_hydronym_lake | 0.000053 |
|
184 |
+
| B-nam_loc_gpe_conurbation | 0.000053 |
|
185 |
+
| B-nam_pro_media | 0.000048 |
|
186 |
+
| I-nam_fac_square | 0.000044 |
|
187 |
+
| B-nam_loc_land | 0.000044 |
|
188 |
+
| B-nam_loc_land_peak | 0.000044 |
|
189 |
+
| B-nam_fac_park | 0.000039 |
|
190 |
+
| B-nam_org_organization_sub | 0.000035 |
|
191 |
+
| I-nam_loc_hydronym_lake | 0.000035 |
|
192 |
+
| B-nam_loc_hydronym | 0.000035 |
|
193 |
+
| I-nam_pro_vehicle | 0.000035 |
|
194 |
+
| I-nam_loc_gpe_conurbation | 0.000035 |
|
195 |
+
| I-nam_fac_goe_stop | 0.000035 |
|
196 |
+
| I-nam_fac_system | 0.000031 |
|
197 |
+
| I-nam_pro_media | 0.000031 |
|
198 |
+
| I-nam_loc_gpe_admin2 | 0.000031 |
|
199 |
+
| I-nam_loc_land | 0.000026 |
|
200 |
+
| B-nam_loc_hydronym_sea | 0.000026 |
|
201 |
+
| B-nam_loc_hydronym_ocean | 0.000026 |
|
202 |
+
| I-nam_org_nation | 0.000026 |
|
203 |
+
| I-nam_liv_character | 0.000022 |
|
204 |
+
| I-nam_oth_www | 0.000022 |
|
205 |
+
| B-nam_fac_goe_stop | 0.000022 |
|
206 |
+
| I-nam_loc_hydronym_sea | 0.000018 |
|
207 |
+
| I-nam_oth_currency | 0.000018 |
|
208 |
+
| I-nam_loc_hydronym | 0.000018 |
|
209 |
+
| I-nam_liv_animal | 0.000018 |
|
210 |
+
| I-nam_loc_hydronym_river | 0.000018 |
|
211 |
+
| I-nam_oth_data_format | 0.000013 |
|
212 |
+
| I-nam_loc_land_continent | 0.000009 |
|
213 |
+
| I-nam_loc_land_peak | 0.000009 |
|
214 |
+
| I-nam_num_house | 0.000009 |
|
215 |
+
| I-nam_loc_hydronym_ocean | 0.000009 |
|
216 |
+
|
217 |
+
## Citation
|
218 |
+
|
219 |
+
```
|
220 |
+
@inproceedings{broda-etal-2012-kpwr,
|
221 |
+
title = "{KPW}r: Towards a Free Corpus of {P}olish",
|
222 |
+
author = "Broda, Bartosz and
|
223 |
+
Marci{\'n}czuk, Micha{\l} and
|
224 |
+
Maziarz, Marek and
|
225 |
+
Radziszewski, Adam and
|
226 |
+
Wardy{\'n}ski, Adam",
|
227 |
+
booktitle = "Proceedings of the Eighth International Conference on Language Resources and Evaluation ({LREC}'12)",
|
228 |
+
month = may,
|
229 |
+
year = "2012",
|
230 |
+
address = "Istanbul, Turkey",
|
231 |
+
publisher = "European Language Resources Association (ELRA)",
|
232 |
+
url = "http://www.lrec-conf.org/proceedings/lrec2012/pdf/965_Paper.pdf",
|
233 |
+
pages = "3218--3222",
|
234 |
+
abstract = "This paper presents our efforts aimed at collecting and annotating a free Polish corpus. The corpus will serve for us as training and testing material for experiments with Machine Learning algorithms. As others may also benefit from the resource, we are going to release it under a Creative Commons licence, which is hoped to remove unnecessary usage restrictions, but also to facilitate reproduction of our experimental results. The corpus is being annotated with various types of linguistic entities: chunks and named entities, selected syntactic and semantic relations, word senses and anaphora. We report on the current state of the project as well as our ultimate goals.",
|
235 |
+
}
|
236 |
+
```
|
237 |
+
|
238 |
+
## License
|
239 |
+
|
240 |
+
```
|
241 |
+
Creative Commons Attribution 3.0 Unported Licence
|
242 |
+
```
|
243 |
+
|
244 |
+
## Links
|
245 |
+
|
246 |
+
[HuggingFace](https://huggingface.co/datasets/clarin-pl/kpwr-ner)
|
247 |
+
|
248 |
+
[Source](https://clarin-pl.eu/index.php/kpwr-en/)
|
249 |
+
|
250 |
+
[Paper](https://aclanthology.org/L12-1574/)
|
251 |
+
|
252 |
+
[KPWr annotation guidelines](http://www.nlp.pwr.wroc.pl/narzedzia-i-zasoby/zasoby/kpwr-lemma/16-narzedzia-zasoby/79-wytyczne)
|
253 |
+
|
254 |
+
[KPWr annotation guidelines - named entities](https://clarin-pl.eu/dspace/handle/11321/294)
|
255 |
+
|
256 |
+
## Examples
|
257 |
+
|
258 |
+
### Loading
|
259 |
+
|
260 |
+
```python
|
261 |
+
from pprint import pprint
|
262 |
+
|
263 |
+
from datasets import load_dataset
|
264 |
+
|
265 |
+
dataset = load_dataset("clarin-pl/kpwr-ner")
|
266 |
+
pprint(dataset['train'][0])
|
267 |
+
|
268 |
+
# {'lemmas': ['roborally', 'czy', 'wysoki', 'napięcie', '?'],
|
269 |
+
# 'ner': [73, 160, 73, 151, 160],
|
270 |
+
# 'orth': ['subst:sg:nom:n',
|
271 |
+
# 'qub',
|
272 |
+
# 'adj:sg:nom:n:pos',
|
273 |
+
# 'subst:sg:nom:n',
|
274 |
+
# 'interp'],
|
275 |
+
# 'tokens': ['RoboRally', 'czy', 'Wysokie', 'napięcie', '?']}
|
276 |
+
```
|
277 |
+
|
278 |
+
### Evaluation
|
279 |
+
|
280 |
+
```python
|
281 |
+
import random
|
282 |
+
from pprint import pprint
|
283 |
+
|
284 |
+
from datasets import load_dataset, load_metric
|
285 |
+
|
286 |
+
dataset = load_dataset("clarin-pl/kpwr-ner")
|
287 |
+
references = dataset["test"]["ner"]
|
288 |
+
|
289 |
+
# generate random predictions
|
290 |
+
predictions = [
|
291 |
+
[
|
292 |
+
random.randrange(dataset["train"].features["ner"].feature.num_classes)
|
293 |
+
for _ in range(len(labels))
|
294 |
+
]
|
295 |
+
for labels in references
|
296 |
+
]
|
297 |
+
|
298 |
+
# transform to original names of labels
|
299 |
+
references_named = [
|
300 |
+
[dataset["train"].features["ner"].feature.names[label] for label in labels]
|
301 |
+
for labels in references
|
302 |
+
]
|
303 |
+
predictions_named = [
|
304 |
+
[dataset["train"].features["ner"].feature.names[label] for label in labels]
|
305 |
+
for labels in predictions
|
306 |
+
]
|
307 |
+
|
308 |
+
# utilise seqeval to evaluate
|
309 |
+
seqeval = load_metric("seqeval")
|
310 |
+
seqeval_score = seqeval.compute(
|
311 |
+
predictions=predictions_named, references=references_named, scheme="IOB2"
|
312 |
+
)
|
313 |
+
|
314 |
+
pprint(seqeval_score, depth=1)
|
315 |
+
|
316 |
+
# {'nam_adj': {...},
|
317 |
+
# 'nam_adj_city': {...},
|
318 |
+
# 'nam_adj_country': {...},
|
319 |
+
# 'nam_adj_person': {...},
|
320 |
+
# 'nam_eve': {...},
|
321 |
+
# 'nam_eve_human': {...},
|
322 |
+
# 'nam_eve_human_cultural': {...},
|
323 |
+
# 'nam_eve_human_holiday': {...},
|
324 |
+
# 'nam_eve_human_sport': {...},
|
325 |
+
# 'nam_fac_bridge': {...},
|
326 |
+
# 'nam_fac_goe': {...},
|
327 |
+
# 'nam_fac_goe_stop': {...},
|
328 |
+
# 'nam_fac_park': {...},
|
329 |
+
# 'nam_fac_road': {...},
|
330 |
+
# 'nam_fac_square': {...},
|
331 |
+
# 'nam_fac_system': {...},
|
332 |
+
# 'nam_liv_animal': {...},
|
333 |
+
# 'nam_liv_character': {...},
|
334 |
+
# 'nam_liv_god': {...},
|
335 |
+
# 'nam_liv_habitant': {...},
|
336 |
+
# 'nam_liv_person': {...},
|
337 |
+
# 'nam_loc': {...},
|
338 |
+
# 'nam_loc_astronomical': {...},
|
339 |
+
# 'nam_loc_country_region': {...},
|
340 |
+
# 'nam_loc_gpe_admin1': {...},
|
341 |
+
# 'nam_loc_gpe_admin2': {...},
|
342 |
+
# 'nam_loc_gpe_admin3': {...},
|
343 |
+
# 'nam_loc_gpe_city': {...},
|
344 |
+
# 'nam_loc_gpe_conurbation': {...},
|
345 |
+
# 'nam_loc_gpe_country': {...},
|
346 |
+
# 'nam_loc_gpe_district': {...},
|
347 |
+
# 'nam_loc_gpe_subdivision': {...},
|
348 |
+
# 'nam_loc_historical_region': {...},
|
349 |
+
# 'nam_loc_hydronym': {...},
|
350 |
+
# 'nam_loc_hydronym_lake': {...},
|
351 |
+
# 'nam_loc_hydronym_ocean': {...},
|
352 |
+
# 'nam_loc_hydronym_river': {...},
|
353 |
+
# 'nam_loc_hydronym_sea': {...},
|
354 |
+
# 'nam_loc_land': {...},
|
355 |
+
# 'nam_loc_land_continent': {...},
|
356 |
+
# 'nam_loc_land_island': {...},
|
357 |
+
# 'nam_loc_land_mountain': {...},
|
358 |
+
# 'nam_loc_land_peak': {...},
|
359 |
+
# 'nam_loc_land_region': {...},
|
360 |
+
# 'nam_num_house': {...},
|
361 |
+
# 'nam_num_phone': {...},
|
362 |
+
# 'nam_org_company': {...},
|
363 |
+
# 'nam_org_group': {...},
|
364 |
+
# 'nam_org_group_band': {...},
|
365 |
+
# 'nam_org_group_team': {...},
|
366 |
+
# 'nam_org_institution': {...},
|
367 |
+
# 'nam_org_nation': {...},
|
368 |
+
# 'nam_org_organization': {...},
|
369 |
+
# 'nam_org_organization_sub': {...},
|
370 |
+
# 'nam_org_political_party': {...},
|
371 |
+
# 'nam_oth': {...},
|
372 |
+
# 'nam_oth_currency': {...},
|
373 |
+
# 'nam_oth_data_format': {...},
|
374 |
+
# 'nam_oth_license': {...},
|
375 |
+
# 'nam_oth_position': {...},
|
376 |
+
# 'nam_oth_tech': {...},
|
377 |
+
# 'nam_oth_www': {...},
|
378 |
+
# 'nam_pro': {...},
|
379 |
+
# 'nam_pro_award': {...},
|
380 |
+
# 'nam_pro_brand': {...},
|
381 |
+
# 'nam_pro_media': {...},
|
382 |
+
# 'nam_pro_media_periodic': {...},
|
383 |
+
# 'nam_pro_media_radio': {...},
|
384 |
+
# 'nam_pro_media_tv': {...},
|
385 |
+
# 'nam_pro_media_web': {...},
|
386 |
+
# 'nam_pro_model_car': {...},
|
387 |
+
# 'nam_pro_software': {...},
|
388 |
+
# 'nam_pro_software_game': {...},
|
389 |
+
# 'nam_pro_title': {...},
|
390 |
+
# 'nam_pro_title_album': {...},
|
391 |
+
# 'nam_pro_title_article': {...},
|
392 |
+
# 'nam_pro_title_book': {...},
|
393 |
+
# 'nam_pro_title_document': {...},
|
394 |
+
# 'nam_pro_title_song': {...},
|
395 |
+
# 'nam_pro_title_treaty': {...},
|
396 |
+
# 'nam_pro_title_tv': {...},
|
397 |
+
# 'nam_pro_vehicle': {...},
|
398 |
+
# 'overall_accuracy': 0.006156203762418094,
|
399 |
+
# 'overall_f1': 0.0009844258777797407,
|
400 |
+
# 'overall_precision': 0.0005213624939842789,
|
401 |
+
# 'overall_recall': 0.008803611738148984}
|
402 |
+
```
|
data/kpwr-ner-n82-test.iob
ADDED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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2021 The TensorFlow Datasets Authors and the 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 |
+
"""KPWR-NER tagging dataset."""
|
18 |
+
|
19 |
+
import csv
|
20 |
+
from typing import List, Tuple, Dict, Generator
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
_DESCRIPTION = """KPWR-NER tagging dataset."""
|
25 |
+
|
26 |
+
_URLS = {
|
27 |
+
"train": "https://huggingface.co/datasets/clarin-pl/kpwr-ner/resolve/main/data/kpwr-ner-n82-train-tune.iob",
|
28 |
+
"test": "https://huggingface.co/datasets/clarin-pl/kpwr-ner/resolve/main/data/kpwr-ner-n82-test.iob",
|
29 |
+
}
|
30 |
+
|
31 |
+
_HOMEPAGE = "https://clarin-pl.eu/dspace/handle/11321/294"
|
32 |
+
|
33 |
+
_NER_TAGS = [
|
34 |
+
"B-nam_adj",
|
35 |
+
"B-nam_adj_city",
|
36 |
+
"B-nam_adj_country",
|
37 |
+
"B-nam_adj_person",
|
38 |
+
"B-nam_eve",
|
39 |
+
"B-nam_eve_human",
|
40 |
+
"B-nam_eve_human_cultural",
|
41 |
+
"B-nam_eve_human_holiday",
|
42 |
+
"B-nam_eve_human_sport",
|
43 |
+
"B-nam_fac_bridge",
|
44 |
+
"B-nam_fac_goe",
|
45 |
+
"B-nam_fac_goe_stop",
|
46 |
+
"B-nam_fac_park",
|
47 |
+
"B-nam_fac_road",
|
48 |
+
"B-nam_fac_square",
|
49 |
+
"B-nam_fac_system",
|
50 |
+
"B-nam_liv_animal",
|
51 |
+
"B-nam_liv_character",
|
52 |
+
"B-nam_liv_god",
|
53 |
+
"B-nam_liv_habitant",
|
54 |
+
"B-nam_liv_person",
|
55 |
+
"B-nam_loc",
|
56 |
+
"B-nam_loc_astronomical",
|
57 |
+
"B-nam_loc_country_region",
|
58 |
+
"B-nam_loc_gpe_admin1",
|
59 |
+
"B-nam_loc_gpe_admin2",
|
60 |
+
"B-nam_loc_gpe_admin3",
|
61 |
+
"B-nam_loc_gpe_city",
|
62 |
+
"B-nam_loc_gpe_conurbation",
|
63 |
+
"B-nam_loc_gpe_country",
|
64 |
+
"B-nam_loc_gpe_district",
|
65 |
+
"B-nam_loc_gpe_subdivision",
|
66 |
+
"B-nam_loc_historical_region",
|
67 |
+
"B-nam_loc_hydronym",
|
68 |
+
"B-nam_loc_hydronym_lake",
|
69 |
+
"B-nam_loc_hydronym_ocean",
|
70 |
+
"B-nam_loc_hydronym_river",
|
71 |
+
"B-nam_loc_hydronym_sea",
|
72 |
+
"B-nam_loc_land",
|
73 |
+
"B-nam_loc_land_continent",
|
74 |
+
"B-nam_loc_land_island",
|
75 |
+
"B-nam_loc_land_mountain",
|
76 |
+
"B-nam_loc_land_peak",
|
77 |
+
"B-nam_loc_land_region",
|
78 |
+
"B-nam_num_house",
|
79 |
+
"B-nam_num_phone",
|
80 |
+
"B-nam_org_company",
|
81 |
+
"B-nam_org_group",
|
82 |
+
"B-nam_org_group_band",
|
83 |
+
"B-nam_org_group_team",
|
84 |
+
"B-nam_org_institution",
|
85 |
+
"B-nam_org_nation",
|
86 |
+
"B-nam_org_organization",
|
87 |
+
"B-nam_org_organization_sub",
|
88 |
+
"B-nam_org_political_party",
|
89 |
+
"B-nam_oth",
|
90 |
+
"B-nam_oth_currency",
|
91 |
+
"B-nam_oth_data_format",
|
92 |
+
"B-nam_oth_license",
|
93 |
+
"B-nam_oth_position",
|
94 |
+
"B-nam_oth_tech",
|
95 |
+
"B-nam_oth_www",
|
96 |
+
"B-nam_pro",
|
97 |
+
"B-nam_pro_award",
|
98 |
+
"B-nam_pro_brand",
|
99 |
+
"B-nam_pro_media",
|
100 |
+
"B-nam_pro_media_periodic",
|
101 |
+
"B-nam_pro_media_radio",
|
102 |
+
"B-nam_pro_media_tv",
|
103 |
+
"B-nam_pro_media_web",
|
104 |
+
"B-nam_pro_model_car",
|
105 |
+
"B-nam_pro_software",
|
106 |
+
"B-nam_pro_software_game",
|
107 |
+
"B-nam_pro_title",
|
108 |
+
"B-nam_pro_title_album",
|
109 |
+
"B-nam_pro_title_article",
|
110 |
+
"B-nam_pro_title_book",
|
111 |
+
"B-nam_pro_title_document",
|
112 |
+
"B-nam_pro_title_song",
|
113 |
+
"B-nam_pro_title_treaty",
|
114 |
+
"B-nam_pro_title_tv",
|
115 |
+
"B-nam_pro_vehicle",
|
116 |
+
"I-nam_adj_country",
|
117 |
+
"I-nam_eve",
|
118 |
+
"I-nam_eve_human",
|
119 |
+
"I-nam_eve_human_cultural",
|
120 |
+
"I-nam_eve_human_holiday",
|
121 |
+
"I-nam_eve_human_sport",
|
122 |
+
"I-nam_fac_bridge",
|
123 |
+
"I-nam_fac_goe",
|
124 |
+
"I-nam_fac_goe_stop",
|
125 |
+
"I-nam_fac_park",
|
126 |
+
"I-nam_fac_road",
|
127 |
+
"I-nam_fac_square",
|
128 |
+
"I-nam_fac_system",
|
129 |
+
"I-nam_liv_animal",
|
130 |
+
"I-nam_liv_character",
|
131 |
+
"I-nam_liv_god",
|
132 |
+
"I-nam_liv_person",
|
133 |
+
"I-nam_loc",
|
134 |
+
"I-nam_loc_astronomical",
|
135 |
+
"I-nam_loc_country_region",
|
136 |
+
"I-nam_loc_gpe_admin1",
|
137 |
+
"I-nam_loc_gpe_admin2",
|
138 |
+
"I-nam_loc_gpe_admin3",
|
139 |
+
"I-nam_loc_gpe_city",
|
140 |
+
"I-nam_loc_gpe_conurbation",
|
141 |
+
"I-nam_loc_gpe_country",
|
142 |
+
"I-nam_loc_gpe_district",
|
143 |
+
"I-nam_loc_gpe_subdivision",
|
144 |
+
"I-nam_loc_historical_region",
|
145 |
+
"I-nam_loc_hydronym",
|
146 |
+
"I-nam_loc_hydronym_lake",
|
147 |
+
"I-nam_loc_hydronym_ocean",
|
148 |
+
"I-nam_loc_hydronym_river",
|
149 |
+
"I-nam_loc_hydronym_sea",
|
150 |
+
"I-nam_loc_land",
|
151 |
+
"I-nam_loc_land_continent",
|
152 |
+
"I-nam_loc_land_island",
|
153 |
+
"I-nam_loc_land_mountain",
|
154 |
+
"I-nam_loc_land_peak",
|
155 |
+
"I-nam_loc_land_region",
|
156 |
+
"I-nam_num_house",
|
157 |
+
"I-nam_num_phone",
|
158 |
+
"I-nam_org_company",
|
159 |
+
"I-nam_org_group",
|
160 |
+
"I-nam_org_group_band",
|
161 |
+
"I-nam_org_group_team",
|
162 |
+
"I-nam_org_institution",
|
163 |
+
"I-nam_org_nation",
|
164 |
+
"I-nam_org_organization",
|
165 |
+
"I-nam_org_organization_sub",
|
166 |
+
"I-nam_org_political_party",
|
167 |
+
"I-nam_oth",
|
168 |
+
"I-nam_oth_currency",
|
169 |
+
"I-nam_oth_data_format",
|
170 |
+
"I-nam_oth_license",
|
171 |
+
"I-nam_oth_position",
|
172 |
+
"I-nam_oth_tech",
|
173 |
+
"I-nam_oth_www",
|
174 |
+
"I-nam_pro",
|
175 |
+
"I-nam_pro_award",
|
176 |
+
"I-nam_pro_brand",
|
177 |
+
"I-nam_pro_media",
|
178 |
+
"I-nam_pro_media_periodic",
|
179 |
+
"I-nam_pro_media_radio",
|
180 |
+
"I-nam_pro_media_tv",
|
181 |
+
"I-nam_pro_media_web",
|
182 |
+
"I-nam_pro_model_car",
|
183 |
+
"I-nam_pro_software",
|
184 |
+
"I-nam_pro_software_game",
|
185 |
+
"I-nam_pro_title",
|
186 |
+
"I-nam_pro_title_album",
|
187 |
+
"I-nam_pro_title_article",
|
188 |
+
"I-nam_pro_title_book",
|
189 |
+
"I-nam_pro_title_document",
|
190 |
+
"I-nam_pro_title_song",
|
191 |
+
"I-nam_pro_title_treaty",
|
192 |
+
"I-nam_pro_title_tv",
|
193 |
+
"I-nam_pro_vehicle",
|
194 |
+
"O",
|
195 |
+
]
|
196 |
+
|
197 |
+
|
198 |
+
class KPWRNER(datasets.GeneratorBasedBuilder):
|
199 |
+
def _info(self) -> datasets.DatasetInfo:
|
200 |
+
return datasets.DatasetInfo(
|
201 |
+
description=_DESCRIPTION,
|
202 |
+
features=datasets.Features(
|
203 |
+
{
|
204 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
205 |
+
"lemmas": datasets.Sequence(datasets.Value("string")),
|
206 |
+
"orth": datasets.Sequence(datasets.Value("string")),
|
207 |
+
"ner": datasets.Sequence(
|
208 |
+
datasets.features.ClassLabel(
|
209 |
+
names=_NER_TAGS, num_classes=len(_NER_TAGS)
|
210 |
+
)
|
211 |
+
),
|
212 |
+
}
|
213 |
+
),
|
214 |
+
homepage=_HOMEPAGE,
|
215 |
+
)
|
216 |
+
|
217 |
+
def _split_generators(
|
218 |
+
self, dl_manager: datasets.DownloadManager
|
219 |
+
) -> List[datasets.SplitGenerator]:
|
220 |
+
urls_to_download = _URLS
|
221 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
222 |
+
return [
|
223 |
+
datasets.SplitGenerator(
|
224 |
+
name=datasets.Split.TRAIN,
|
225 |
+
gen_kwargs={"filepath": downloaded_files["train"]},
|
226 |
+
),
|
227 |
+
datasets.SplitGenerator(
|
228 |
+
name=datasets.Split.TEST,
|
229 |
+
gen_kwargs={"filepath": downloaded_files["test"]},
|
230 |
+
),
|
231 |
+
]
|
232 |
+
|
233 |
+
def _generate_examples(
|
234 |
+
self, filepath: str
|
235 |
+
) -> Generator[Tuple[int, Dict[str, str]], None, None]:
|
236 |
+
with open(filepath, "r", encoding="utf-8") as f:
|
237 |
+
reader = csv.reader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
|
238 |
+
|
239 |
+
tokens = []
|
240 |
+
lemma = []
|
241 |
+
orth = []
|
242 |
+
ner = []
|
243 |
+
gid = 0
|
244 |
+
|
245 |
+
for line in reader:
|
246 |
+
if not line:
|
247 |
+
yield gid, {
|
248 |
+
"tokens": tokens,
|
249 |
+
"lemmas": lemma,
|
250 |
+
"orth": orth,
|
251 |
+
"ner": ner,
|
252 |
+
}
|
253 |
+
gid += 1
|
254 |
+
tokens = []
|
255 |
+
lemma = []
|
256 |
+
orth = []
|
257 |
+
ner = []
|
258 |
+
|
259 |
+
elif len(line) == 1: # ignore DOCS
|
260 |
+
continue
|
261 |
+
|
262 |
+
else:
|
263 |
+
tokens.append(line[0])
|
264 |
+
lemma.append(line[1])
|
265 |
+
orth.append(line[2])
|
266 |
+
ner.append(line[3])
|