Albert Sawczyn commited on
Commit
018aeee
1 Parent(s): b42580d

add README.md

Browse files
Files changed (1) hide show
  1. README.md +237 -0
README.md ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - other
6
+ languages:
7
+ - pl
8
+ licenses:
9
+ - gpl-3.0
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: 'nkjp-pos'
13
+ size_categories:
14
+ - unknown
15
+ source_datasets:
16
+ - original
17
+ task_categories:
18
+ - structure-prediction
19
+ task_ids:
20
+ - part-of-speech-tagging
21
+ ---
22
+
23
+ # nkjp-pos
24
+
25
+ ## Description
26
+
27
+ 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.
28
+
29
+ ## Tasks (input, output and metrics)
30
+
31
+ Part-of-speech tagging (POS tagging) - tagging words in text with their corresponding part of speech.
32
+
33
+ **Input** ('*tokens'* column): sequence of tokens
34
+
35
+ **Output** ('*pos_tags'* column): sequence of predicted tokens’ classes (35 possible classes, described in detail in the annotation guidelines)
36
+
37
+ ***example**:*
38
+
39
+ [*'Zarejestruj', 'się', 'jako', 'bezrobotny', '.'*] → [*'impt', 'qub', 'conj', 'subst', 'interp'*]
40
+
41
+ Measurements:
42
+
43
+ ## Data splits
44
+
45
+ | Subset | Cardinality (sentences) |
46
+ | ----------- | ----------------------: |
47
+ | train | 68528 |
48
+ | val | 8566 |
49
+ | test | 8566 |
50
+
51
+
52
+ ## Class distribution in train
53
+
54
+
55
+ | Class | Fraction of tokens |
56
+ |:--------|---------------------:|
57
+ | subst | 0.27295 |
58
+ | interp | 0.18381 |
59
+ | adj | 0.10607 |
60
+ | prep | 0.09533 |
61
+ | qub | 0.05633 |
62
+ | fin | 0.04895 |
63
+ | praet | 0.04385 |
64
+ | conj | 0.03685 |
65
+ | adv | 0.03498 |
66
+ | inf | 0.01586 |
67
+ | comp | 0.01465 |
68
+ | num | 0.01319 |
69
+ | ppron3 | 0.01090 |
70
+ | ppas | 0.01080 |
71
+ | ger | 0.00967 |
72
+ | brev | 0.00880 |
73
+ | ppron12 | 0.00668 |
74
+ | aglt | 0.00620 |
75
+ | pred | 0.00536 |
76
+ | pact | 0.00452 |
77
+ | bedzie | 0.00232 |
78
+ | pcon | 0.00216 |
79
+ | impt | 0.00201 |
80
+ | siebie | 0.00175 |
81
+ | imps | 0.00172 |
82
+ | interj | 0.00128 |
83
+ | xxx | 0.00067 |
84
+ | winien | 0.00066 |
85
+ | adjp | 0.00066 |
86
+ | adja | 0.00048 |
87
+ | pant | 0.00013 |
88
+ | depr | 0.00010 |
89
+ | burk | 0.00010 |
90
+ | numcol | 0.00010 |
91
+ | adjc | 0.00007 |
92
+
93
+
94
+ ## Citation
95
+
96
+ ```
97
+ @book{przepiorkowski_narodowy_2012,
98
+ title = {Narodowy korpus języka polskiego},
99
+ isbn = {978-83-01-16700-4},
100
+ language = {pl},
101
+ publisher = {Wydawnictwo Naukowe PWN},
102
+ editor = {Przepiórkowski, Adam and Bańko, Mirosław and Górski, Rafał L. and Lewandowska-Tomaszczyk, Barbara},
103
+ year = {2012}
104
+ }
105
+ ```
106
+
107
+ ## License
108
+
109
+ ```
110
+ GNU GPL v.3
111
+ ```
112
+
113
+ ## Links
114
+
115
+ [HuggingFace](https://huggingface.co/datasets/clarin-pl/nkjp-pos)
116
+
117
+ [Source](http://clip.ipipan.waw.pl/NationalCorpusOfPolish)
118
+
119
+ [Paper](http://nkjp.pl/settings/papers/NKJP_ksiazka.pdf)
120
+
121
+ ## Examples
122
+
123
+ ### Loading
124
+
125
+ ```python
126
+ from pprint import pprint
127
+
128
+ from datasets import load_dataset
129
+
130
+ dataset = load_dataset("clarin-pl/nkjp-pos")
131
+ pprint(dataset['train'][5000])
132
+
133
+ # {'full_pos_tags': ['fin:sg:ter:imperf',
134
+ # 'subst:sg:nom:f',
135
+ # 'adj:sg:nom:f:pos',
136
+ # 'interp'],
137
+ # 'lemmas': ['trwać', 'akcja', 'poszukiwawczy', '.'],
138
+ # 'morph': ['trwać|fin:sg:ter:imperf',
139
+ # 'akcja|subst:sg:nom:f',
140
+ # 'poszukiwawczy|adj:sg:nom:f:pos poszukiwawczy|adj:sg:voc:f:pos',
141
+ # '.|interp'],
142
+ # 'nps': ['', '', 'nps', ''],
143
+ # 'pos_tags': [12, 32, 0, 18],
144
+ # 'tokens': ['Trwa', 'akcja', 'poszukiwawcza', '.']}
145
+ ```
146
+
147
+ ### Evaluation
148
+
149
+ ```python
150
+ import random
151
+ from pprint import pprint
152
+
153
+ from datasets import load_dataset, load_metric
154
+
155
+ dataset = load_dataset("clarin-pl/nkjp-pos")
156
+ references = dataset["test"]["pos_tags"]
157
+
158
+ # generate random predictions
159
+ predictions = [
160
+ [
161
+ random.randrange(dataset["train"].features["pos_tags"].feature.num_classes)
162
+ for _ in range(len(labels))
163
+ ]
164
+ for labels in references
165
+ ]
166
+
167
+ # transform to original names of labels
168
+ references_named = [
169
+ [dataset["train"].features["pos_tags"].feature.names[label] for label in labels]
170
+ for labels in references
171
+ ]
172
+ predictions_named = [
173
+ [dataset["train"].features["pos_tags"].feature.names[label] for label in labels]
174
+ for labels in predictions
175
+ ]
176
+
177
+ # transform to BILOU scheme
178
+ references_named = [
179
+ [f"U-{label}" if label != "O" else label for label in labels]
180
+ for labels in references_named
181
+ ]
182
+ predictions_named = [
183
+ [f"U-{label}" if label != "O" else label for label in labels]
184
+ for labels in predictions_named
185
+ ]
186
+
187
+ # utilise seqeval to evaluate
188
+ seqeval = load_metric("seqeval")
189
+ seqeval_score = seqeval.compute(
190
+ predictions=predictions_named,
191
+ references=references_named,
192
+ scheme="BILOU",
193
+ mode="strict",
194
+ )
195
+
196
+ pprint(seqeval_score, depth=1)
197
+
198
+ # {'adj': {...},
199
+ # 'adja': {...},
200
+ # 'adjc': {...},
201
+ # 'adjp': {...},
202
+ # 'adv': {...},
203
+ # 'aglt': {...},
204
+ # 'bedzie': {...},
205
+ # 'brev': {...},
206
+ # 'burk': {...},
207
+ # 'comp': {...},
208
+ # 'conj': {...},
209
+ # 'depr': {...},
210
+ # 'fin': {...},
211
+ # 'ger': {...},
212
+ # 'imps': {...},
213
+ # 'impt': {...},
214
+ # 'inf': {...},
215
+ # 'interj': {...},
216
+ # 'interp': {...},
217
+ # 'num': {...},
218
+ # 'numcol': {...},
219
+ # 'overall_accuracy': 0.027855061488566583,
220
+ # 'overall_f1': 0.027855061488566583,
221
+ # 'overall_precision': 0.027855061488566583,
222
+ # 'overall_recall': 0.027855061488566583,
223
+ # 'pact': {...},
224
+ # 'pant': {...},
225
+ # 'pcon': {...},
226
+ # 'ppas': {...},
227
+ # 'ppron12': {...},
228
+ # 'ppron3': {...},
229
+ # 'praet': {...},
230
+ # 'pred': {...},
231
+ # 'prep': {...},
232
+ # 'qub': {...},
233
+ # 'siebie': {...},
234
+ # 'subst': {...},
235
+ # 'winien': {...},
236
+ # 'xxx': {...}}
237
+ ```