Datasets:
Tasks:
Other
Modalities:
Text
Sub-tasks:
part-of-speech
Languages:
Polish
Size:
10K - 100K
Tags:
structure-prediction
License:
annotations_creators: | |
- expert-generated | |
language_creators: | |
- other | |
languages: | |
- pl | |
licenses: | |
- gpl-3.0 | |
multilinguality: | |
- monolingual | |
pretty_name: 'nkjp-pos' | |
size_categories: | |
- unknown | |
source_datasets: | |
- original | |
task_categories: | |
- structure-prediction | |
task_ids: | |
- part-of-speech-tagging | |
# nkjp-pos | |
## Description | |
NKJP-POS is a part the National Corpus of Polish (*Narodowy Korpus Języka Polskiego*). Its objective is part-of-speech tagging, e.g. nouns, verbs, adjectives, adverbs, etc. During the creation of corpus, texts of were annotated by humans from various sources, covering many domains and genres. | |
## Tasks (input, output and metrics) | |
Part-of-speech tagging (POS tagging) - tagging words in text with their corresponding part of speech. | |
**Input** ('*tokens'* column): sequence of tokens | |
**Output** ('*pos_tags'* column): sequence of predicted tokens’ classes (35 possible classes, described in detail in the annotation guidelines) | |
***example**:* | |
['Najwyraźniej', 'źle', 'ocenił', 'odległość', ',', 'bo', 'zderzył', 'się', 'z', 'jadącą', 'z', 'naprzeciwka', 'ciężarową', 'scanią', '.'] → ['qub', 'adv', 'praet', 'subst', 'interp', 'comp', 'praet', 'qub', 'prep', 'pact', 'prep', 'burk', 'adj', 'subst', 'interp'] | |
Measurements: | |
## Data splits | |
| Subset | Cardinality (sentences) | | |
| ----------- | ----------------------: | | |
| train | 78219 | | |
| test | 7444 | | |
## Class distribution in train | |
| Class | Fraction of tokens | | |
|:--------|---------------------:| | |
| subst | 0.27345 | | |
| interp | 0.18101 | | |
| adj | 0.10611 | | |
| prep | 0.09567 | | |
| qub | 0.05670 | | |
| fin | 0.04939 | | |
| praet | 0.04409 | | |
| conj | 0.03711 | | |
| adv | 0.03512 | | |
| inf | 0.01591 | | |
| comp | 0.01476 | | |
| num | 0.01322 | | |
| ppron3 | 0.01111 | | |
| ppas | 0.01086 | | |
| ger | 0.00961 | | |
| brev | 0.00856 | | |
| ppron12 | 0.00670 | | |
| aglt | 0.00629 | | |
| pred | 0.00539 | | |
| pact | 0.00454 | | |
| bedzie | 0.00229 | | |
| pcon | 0.00218 | | |
| impt | 0.00203 | | |
| siebie | 0.00177 | | |
| imps | 0.00174 | | |
| interj | 0.00131 | | |
| xxx | 0.00070 | | |
| adjp | 0.00069 | | |
| winien | 0.00068 | | |
| adja | 0.00048 | | |
| pant | 0.00012 | | |
| burk | 0.00011 | | |
| numcol | 0.00011 | | |
| depr | 0.00010 | | |
| adjc | 0.00007 | | |
## Citation | |
``` | |
@book{przepiorkowski_narodowy_2012, | |
title = {Narodowy korpus języka polskiego}, | |
isbn = {978-83-01-16700-4}, | |
language = {pl}, | |
publisher = {Wydawnictwo Naukowe PWN}, | |
editor = {Przepiórkowski, Adam and Bańko, Mirosław and Górski, Rafał L. and Lewandowska-Tomaszczyk, Barbara}, | |
year = {2012} | |
} | |
``` | |
## License | |
``` | |
GNU GPL v.3 | |
``` | |
## Links | |
[HuggingFace](https://huggingface.co/datasets/clarin-pl/nkjp-pos) | |
[Source](http://clip.ipipan.waw.pl/NationalCorpusOfPolish) | |
[Paper](http://nkjp.pl/settings/papers/NKJP_ksiazka.pdf) | |
## Examples | |
### Loading | |
```python | |
from pprint import pprint | |
from datasets import load_dataset | |
dataset = load_dataset("clarin-pl/nkjp-pos") | |
pprint(dataset['train'][5000]) | |
# {'id': '130-2-900005_morph_49.49-s', | |
# 'pos_tags': [16, 4, 3, 30, 12, 18, 3, 16, 14, 6, 14, 26, 1, 30, 12], | |
# 'tokens': ['Najwyraźniej', | |
# 'źle', | |
# 'ocenił', | |
# 'odległość', | |
# ',', | |
# 'bo', | |
# 'zderzył', | |
# 'się', | |
# 'z', | |
# 'jadącą', | |
# 'z', | |
# 'naprzeciwka', | |
# 'ciężarową', | |
# 'scanią', | |
# '.']} | |
``` | |
### Evaluation | |
```python | |
import random | |
from pprint import pprint | |
from datasets import load_dataset, load_metric | |
dataset = load_dataset("clarin-pl/nkjp-pos") | |
references = dataset["test"]["pos_tags"] | |
# generate random predictions | |
predictions = [ | |
[ | |
random.randrange(dataset["train"].features["pos_tags"].feature.num_classes) | |
for _ in range(len(labels)) | |
] | |
for labels in references | |
] | |
# transform to original names of labels | |
references_named = [ | |
[dataset["train"].features["pos_tags"].feature.names[label] for label in labels] | |
for labels in references | |
] | |
predictions_named = [ | |
[dataset["train"].features["pos_tags"].feature.names[label] for label in labels] | |
for labels in predictions | |
] | |
# transform to BILOU scheme | |
references_named = [ | |
[f"U-{label}" if label != "O" else label for label in labels] | |
for labels in references_named | |
] | |
predictions_named = [ | |
[f"U-{label}" if label != "O" else label for label in labels] | |
for labels in predictions_named | |
] | |
# utilise seqeval to evaluate | |
seqeval = load_metric("seqeval") | |
seqeval_score = seqeval.compute( | |
predictions=predictions_named, | |
references=references_named, | |
scheme="BILOU", | |
mode="strict", | |
) | |
pprint(seqeval_score, depth=1) | |
# {'adj': {...}, | |
# 'adja': {...}, | |
# 'adjc': {...}, | |
# 'adjp': {...}, | |
# 'adv': {...}, | |
# 'aglt': {...}, | |
# 'bedzie': {...}, | |
# 'brev': {...}, | |
# 'burk': {...}, | |
# 'comp': {...}, | |
# 'conj': {...}, | |
# 'depr': {...}, | |
# 'fin': {...}, | |
# 'ger': {...}, | |
# 'imps': {...}, | |
# 'impt': {...}, | |
# 'inf': {...}, | |
# 'interj': {...}, | |
# 'interp': {...}, | |
# 'num': {...}, | |
# 'numcol': {...}, | |
# 'overall_accuracy': 0.027855061488566583, | |
# 'overall_f1': 0.027855061488566583, | |
# 'overall_precision': 0.027855061488566583, | |
# 'overall_recall': 0.027855061488566583, | |
# 'pact': {...}, | |
# 'pant': {...}, | |
# 'pcon': {...}, | |
# 'ppas': {...}, | |
# 'ppron12': {...}, | |
# 'ppron3': {...}, | |
# 'praet': {...}, | |
# 'pred': {...}, | |
# 'prep': {...}, | |
# 'qub': {...}, | |
# 'siebie': {...}, | |
# 'subst': {...}, | |
# 'winien': {...}, | |
# 'xxx': {...}} | |
``` |