File size: 6,183 Bytes
018aeee
 
 
 
 
9d2d716
018aeee
9d2d716
018aeee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c03bf2e
018aeee
c03bf2e
018aeee
c03bf2e
 
 
 
 
018aeee
 
 
 
 
d90b6bd
c436860
d90b6bd
018aeee
 
c436860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
018aeee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d90b6bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
018aeee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
---
annotations_creators:
- expert-generated
language_creators:
- other
language:
- pl
license:
- 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)

**Measurements**: F1-score (seqeval)

**Example***:*

Input: `['Zarejestruj', 'się', 'jako', 'bezrobotny', '.']`

Input (translated by DeepL): `Register as unemployed.`

Output:  `['impt', 'qub', 'conj', 'subst', 'interp']`

## Data splits

| Subset      | Cardinality (sentences) |
| ----------- | ----------------------: |
| train       | 78219                   |
| dev         | 0                       |
| test        | 7444                    |


## Class distribution


| Class   |   train | dev   |    test |
|:--------|--------:|------:|--------:|
| subst   | 0.27345 | -     | 0.27656 |
| interp  | 0.18101 | -     | 0.17944 |
| adj     | 0.10611 | -     | 0.10919 |
| prep    | 0.09567 | -     | 0.09547 |
| qub     | 0.05670 | -     | 0.05491 |
| fin     | 0.04939 | -     | 0.04648 |
| praet   | 0.04409 | -     | 0.04348 |
| conj    | 0.03711 | -     | 0.03724 |
| adv     | 0.03512 | -     | 0.03333 |
| inf     | 0.01591 | -     | 0.01547 |
| comp    | 0.01476 | -     | 0.01439 |
| num     | 0.01322 | -     | 0.01436 |
| ppron3  | 0.01111 | -     | 0.01018 |
| ppas    | 0.01086 | -     | 0.01085 |
| ger     | 0.00961 | -     | 0.01050 |
| brev    | 0.00856 | -     | 0.01181 |
| ppron12 | 0.00670 | -     | 0.00665 |
| aglt    | 0.00629 | -     | 0.00602 |
| pred    | 0.00539 | -     | 0.00540 |
| pact    | 0.00454 | -     | 0.00452 |
| bedzie  | 0.00229 | -     | 0.00243 |
| pcon    | 0.00218 | -     | 0.00189 |
| impt    | 0.00203 | -     | 0.00226 |
| siebie  | 0.00177 | -     | 0.00158 |
| imps    | 0.00174 | -     | 0.00177 |
| interj  | 0.00131 | -     | 0.00102 |
| xxx     | 0.00070 | -     | 0.00048 |
| adjp    | 0.00069 | -     | 0.00065 |
| winien  | 0.00068 | -     | 0.00057 |
| adja    | 0.00048 | -     | 0.00058 |
| pant    | 0.00012 | -     | 0.00018 |
| burk    | 0.00011 | -     | 0.00006 |
| numcol  | 0.00011 | -     | 0.00013 |
| depr    | 0.00010 | -     | 0.00004 |
| adjc    | 0.00007 | -     | 0.00008 |


## 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': {...}}
```