Datasets:

Languages:
Norwegian
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
crowdsourced
Annotations Creators:
expert-generated
Source Datasets:
original
ArXiv:
License:
system HF staff commited on
Commit
5684c51
1 Parent(s): 2b91f80

import from S3

Browse files
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - crowdsourced
6
+ languages:
7
+ - no
8
+ licenses:
9
+ - other-national-library-of-norway
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ - 10K<n<100K
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - structure-prediction
18
+ task_ids:
19
+ - named-entity-recognition
20
+ ---
21
+
22
+ # Dataset Card for NorNE: Norwegian Named Entities
23
+
24
+ ## Table of Contents
25
+
26
+ - [Dataset Description](#dataset-description)
27
+ - [Dataset Summary](#dataset-summary)
28
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
29
+ - [Languages](#languages)
30
+ - [Dataset Structure](#dataset-structure)
31
+ - [Data Instances](#data-instances)
32
+ - [Data Fields](#data-instances)
33
+ - [Data Splits](#data-instances)
34
+ - [Dataset Creation](#dataset-creation)
35
+ - [Curation Rationale](#curation-rationale)
36
+ - [Source Data](#source-data)
37
+ - [Annotations](#annotations)
38
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
39
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
40
+ - [Social Impact of Dataset](#social-impact-of-dataset)
41
+ - [Discussion of Biases](#discussion-of-biases)
42
+ - [Other Known Limitations](#other-known-limitations)
43
+ - [Additional Information](#additional-information)
44
+ - [Dataset Curators](#dataset-curators)
45
+ - [Licensing Information](#licensing-information)
46
+ - [Citation Information](#citation-information)
47
+
48
+ ## Dataset Description
49
+
50
+ - **Homepage:** [NorNE](https://github.com/ltgoslo/norne/)
51
+ - **Repository:** [Github](https://github.com/ltgoslo/norne/)
52
+ - **Paper:** https://arxiv.org/abs/1911.12146
53
+ - **Leaderboard:**
54
+ - **Point of Contact:**
55
+
56
+ ### Dataset Summary
57
+
58
+ NorNE is a manually annotated corpus of named entities which extends the annotation of the existing Norwegian Dependency Treebank. Comprising both of the official standards of written Norwegian (Bokmål and Nynorsk), the corpus contains around 600,000 tokens and annotates a rich set of entity types including persons,organizations, locations, geo-political entities, products, and events, in addition to a class corresponding to nominals derived from names.
59
+
60
+ ### Supported Tasks and Leaderboards
61
+
62
+ NorNE ads named entity annotations on top of the Norwegian Dependency Treebank.
63
+
64
+ ### Languages
65
+
66
+ Both Norwegian Bokmål (`bookmal`) and Nynorsk (`nynorsk`) are supported as different configs in this dataset.
67
+
68
+ ## Dataset Creation
69
+
70
+ ### Curation Rationale
71
+
72
+ 1. A _name_ in this context is close to [Saul Kripke's definition of a name](https://en.wikipedia.org/wiki/Saul_Kripke#Naming_and_Necessity),
73
+ in that a name has a unique reference and its meaning is constant (there are exceptions in the annotations, e.g. "Regjeringen" (en. "Government")).
74
+ 2. It is the usage of a name that determines the entity type, not the default/literal sense of the name,
75
+ 3. If there is an ambiguity in the type/sense of a name, then the the default/literal sense of the name is chosen
76
+ (following [Markert and Nissim, 2002](http://www.lrec-conf.org/proceedings/lrec2002/pdf/11.pdf)).
77
+
78
+ For more details, see the "Annotation Guidelines.pdf" distributed with the corpus.
79
+
80
+ ### Source Data
81
+
82
+ Data was collected using blogs and newspapers in Norwegian, as well as parliament speeches and governamental reports.
83
+
84
+ #### Initial Data Collection and Normalization
85
+
86
+ The texts in the Norwegian Dependency Treebank (NDT) are manually annotated with morphological features, syntactic functions
87
+ and hierarchical structure. The formalism used for the syntactic annotation is dependency grammar.
88
+
89
+ The treebanks consists of two parts, one part in Norwegian Bokmål (`nob`) and one part in Norwegian Nynorsk (`nno`).
90
+ Both parts contain around 300.000 tokens, and are a mix of different non-fictional genres.
91
+
92
+ See the [NDT webpage](https://www.nb.no/sprakbanken/show?serial=sbr-10) for more details.
93
+
94
+ ### Annotations
95
+
96
+ The following types of entities are annotated:
97
+
98
+ - **Person (`PER`):** Real or fictional characters and animals
99
+ - **Organization (`ORG`):** Any collection of people, such as firms, institutions, organizations, music groups,
100
+ sports teams, unions, political parties etc.
101
+ - **Location (`LOC`):** Geographical places, buildings and facilities
102
+ - **Geo-political entity (`GPE`):** Geographical regions defined by political and/or social groups.
103
+ A GPE entity subsumes and does not distinguish between a nation, its region, its government, or its people
104
+ - **Product (`PROD`):** Artificially produced entities are regarded products. This may include more abstract entities, such as speeches,
105
+ radio shows, programming languages, contracts, laws and ideas.
106
+ - **Event (`EVT`):** Festivals, cultural events, sports events, weather phenomena, wars, etc. Events are bounded in time and space.
107
+ - **Derived (`DRV`):** Words (and phrases?) that are dervied from a name, but not a name in themselves. They typically contain a full name and are capitalized, but are not proper nouns. Examples (fictive) are "Brann-treneren" ("the Brann coach") or "Oslo-mannen" ("the man from Oslo").
108
+ - **Miscellaneous (`MISC`):** Names that do not belong in the other categories. Examples are animals species and names of medical conditions. Entities that are manufactured or produced are of type Products, whereas thing naturally or spontaneously occurring are of type Miscellaneous.
109
+
110
+ Furthermore, all `GPE` entities are additionally sub-categorized as being either `ORG` or `LOC`, with the two annotation levels separated by an underscore:
111
+
112
+ - `GPE_LOC`: Geo-political entity, with a locative sense (e.g. "John lives in _Spain_")
113
+ - `GPE_ORG`: Geo-political entity, with an organisation sense (e.g. "_Spain_ declined to meet with Belgium")
114
+
115
+ The two special types `GPE_LOC` and `GPE_ORG` can easily be altered depending on the task, choosing either the more general `GPE` tag or the more specific `LOC`/`ORG` tags, conflating them with the other annotations of the same type. This means that the following sets of entity types can be derived:
116
+
117
+ - 7 types, deleting `_GPE`: **`ORG`**, **`LOC`**, `PER`, `PROD`, `EVT`, `DRV`, `MISC`
118
+ - 8 types, deleting `LOC_` and `ORG_`: **`ORG`**, **`LOC`**, **`GPE`**, `PER`, `PROD`, `EVT`, `DRV`, `MISC`
119
+ - 9 types, keeping all types: **`ORG`**, **`LOC`**, **`GPE_LOC`**, **`GPE_ORG`**, `PER`, `PROD`, `EVT`, `DRV`, `MISC`
120
+
121
+ The class distribution is as follows, broken down across the data splits of the UD version of NDT, and sorted by total counts (i.e. the number of examples, not tokens within the spans of the annotatons):
122
+
123
+ | Type | Train | Dev | Test | Total |
124
+ | :--------|-------:|-------:|-------:|-------:|
125
+ | `PER` | 4033 | 607 | 560 | 5200 |
126
+ | `ORG` | 2828 | 400 | 283 | 3511 |
127
+ | `GPE_LOC`| 2132 | 258 | 257 | 2647 |
128
+ | `PROD` | 671 | 162 | 71 | 904 |
129
+ | `LOC` | 613 | 109 | 103 | 825 |
130
+ | `GPE_ORG`| 388 | 55 | 50 | 493 |
131
+ | `DRV` | 519 | 77 | 48 | 644 |
132
+ | `EVT` | 131 | 9 | 5 | 145 |
133
+ | `MISC` | 8 | 0 | 0 | 0 |
134
+
135
+ ## Additional Information
136
+
137
+ ### Dataset Curators
138
+
139
+ NorNE was created as a collaboration between [Schibsted Media Group](https://schibsted.com/), [Språkbanken](https://www.nb.no/forskning/sprakbanken/) at the [National Library of Norway](https://www.nb.no) and the [Language Technology Group](https://www.mn.uio.no/ifi/english/research/groups/ltg/) at the University of Oslo.
140
+
141
+ NorNE was added to Huggingface Datasets by the AI-Lab at the National Library of Norway.
142
+
143
+ ### Licensing Information
144
+
145
+ The NorNE corpus is published under the same [license](https://github.com/ltgoslo/norne/blob/master/LICENSE_NDT.txt) as the Norwegian Dependency Treebank
146
+
147
+ ### Citation Information
148
+
149
+ This dataset is described in the paper _NorNE: Annotating Named Entities for Norwegian_ by
150
+ Fredrik Jørgensen, Tobias Aasmoe, Anne-Stine Ruud Husevåg, Lilja Øvrelid, and Erik Velldal, accepted for LREC 2020 and available as pre-print here: https://arxiv.org/abs/1911.12146.
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bokmaal": {"description": "NorNE is a manually annotated\ncorpus of named entities which extends the annotation of the existing\nNorwegian Dependency Treebank. Comprising both of the official standards of\nwritten Norwegian (Bokm\u00e5l and Nynorsk), the corpus contains around 600,000\ntokens and annotates a rich set of entity types including persons,\norganizations, locations, geo-political entities, products, and events,\nin addition to a class corresponding to nominals derived from names.\n", "citation": "@inproceedings{johansen2019ner,\n title={NorNE: Annotating Named Entities for Norwegian},\n author={Fredrik J\u00f8rgensen, Tobias Aasmoe, Anne-Stine Ruud Husev\u00e5g,\n Lilja \u00d8vrelid, and Erik Velldal},\n booktitle={LREC 2020},\n year={2020},\n url={https://arxiv.org/abs/1911.12146}\n}\n", "homepage": "https://github.com/ltgoslo/norne", "license": "", "features": {"idx": {"dtype": "string", "id": null, "_type": "Value"}, "lang": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "lemmas": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "pos_tags": {"feature": {"num_classes": 17, "names": ["NOUN", "PUNCT", "ADP", "NUM", "SYM", "SCONJ", "ADJ", "PART", "DET", "CCONJ", "PROPN", "PRON", "X", "ADV", "INTJ", "VERB", "AUX"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 19, "names": ["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-GPE_LOC", "I-GPE_LOC", "B-PROD", "I-PROD", "B-LOC", "I-LOC", "B-GPE_ORG", "I-GPE_ORG", "B-DRV", "I-DRV", "B-EVT", "I-EVT", "B-MISC", "I-MISC"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "norne", "config_name": "bokmaal", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 10032169, "num_examples": 15696, "dataset_name": "norne"}, "validation": {"name": "validation", "num_bytes": 1501730, "num_examples": 2410, "dataset_name": "norne"}, "test": {"name": "test", "num_bytes": 1234272, "num_examples": 1939, "dataset_name": "norne"}}, "download_checksums": {"https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nob/no_bokmaal-ud-train.conllu": {"num_bytes": 16437262, "checksum": "b17efd70034071f65ba5e3a15bc15f9a597f4c1dd3febb2ffec964906a9c1a98"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nob/no_bokmaal-ud-dev.conllu": {"num_bytes": 2453504, "checksum": "dba752ca6dc0c628f7cf12e9131b2627be0dff082bd96311bafce40590c46f9c"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nob/no_bokmaal-ud-test.conllu": {"num_bytes": 2018475, "checksum": "ace6fa65758541333e6a64210fa8466145e024cbbab18a156e8757c8b21c103b"}}, "download_size": 20909241, "post_processing_size": null, "dataset_size": 12768171, "size_in_bytes": 33677412}, "nynorsk": {"description": "NorNE is a manually annotated\ncorpus of named entities which extends the annotation of the existing\nNorwegian Dependency Treebank. Comprising both of the official standards of\nwritten Norwegian (Bokm\u00e5l and Nynorsk), the corpus contains around 600,000\ntokens and annotates a rich set of entity types including persons,\norganizations, locations, geo-political entities, products, and events,\nin addition to a class corresponding to nominals derived from names.\n", "citation": "@inproceedings{johansen2019ner,\n title={NorNE: Annotating Named Entities for Norwegian},\n author={Fredrik J\u00f8rgensen, Tobias Aasmoe, Anne-Stine Ruud Husev\u00e5g,\n Lilja \u00d8vrelid, and Erik Velldal},\n booktitle={LREC 2020},\n year={2020},\n url={https://arxiv.org/abs/1911.12146}\n}\n", "homepage": "https://github.com/ltgoslo/norne", "license": "", "features": {"idx": {"dtype": "string", "id": null, "_type": "Value"}, "lang": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "lemmas": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "pos_tags": {"feature": {"num_classes": 17, "names": ["NOUN", "PUNCT", "ADP", "NUM", "SYM", "SCONJ", "ADJ", "PART", "DET", "CCONJ", "PROPN", "PRON", "X", "ADV", "INTJ", "VERB", "AUX"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 19, "names": ["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-GPE_LOC", "I-GPE_LOC", "B-PROD", "I-PROD", "B-LOC", "I-LOC", "B-GPE_ORG", "I-GPE_ORG", "B-DRV", "I-DRV", "B-EVT", "I-EVT", "B-MISC", "I-MISC"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "norne", "config_name": "nynorsk", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 10072260, "num_examples": 14174, "dataset_name": "norne"}, "validation": {"name": "validation", "num_bytes": 1278029, "num_examples": 1890, "dataset_name": "norne"}, "test": {"name": "test", "num_bytes": 1023358, "num_examples": 1511, "dataset_name": "norne"}}, "download_checksums": {"https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nno/no_nynorsk-ud-train.conllu": {"num_bytes": 16444176, "checksum": "589564c68ab0763c2574ad90ea8928f029144c966e4af064e59a0865c53c5ef2"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nno/no_nynorsk-ud-dev.conllu": {"num_bytes": 2096713, "checksum": "6519a00c0ddc4f8ef2605d7c5326adcafb2dfa2df439e281c95e1a0ef218b928"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nno/no_nynorsk-ud-test.conllu": {"num_bytes": 1668364, "checksum": "6b99cafd7019ed6d1eea1b51a0707df89cad597fe588b5987b9f278ffd87588c"}}, "download_size": 20209253, "post_processing_size": null, "dataset_size": 12373647, "size_in_bytes": 32582900}, "combined": {"description": "NorNE is a manually annotated\ncorpus of named entities which extends the annotation of the existing\nNorwegian Dependency Treebank. Comprising both of the official standards of\nwritten Norwegian (Bokm\u00e5l and Nynorsk), the corpus contains around 600,000\ntokens and annotates a rich set of entity types including persons,\norganizations, locations, geo-political entities, products, and events,\nin addition to a class corresponding to nominals derived from names.\n", "citation": "@inproceedings{johansen2019ner,\n title={NorNE: Annotating Named Entities for Norwegian},\n author={Fredrik J\u00f8rgensen, Tobias Aasmoe, Anne-Stine Ruud Husev\u00e5g,\n Lilja \u00d8vrelid, and Erik Velldal},\n booktitle={LREC 2020},\n year={2020},\n url={https://arxiv.org/abs/1911.12146}\n}\n", "homepage": "https://github.com/ltgoslo/norne", "license": "", "features": {"idx": {"dtype": "string", "id": null, "_type": "Value"}, "lang": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "tokens": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "lemmas": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "pos_tags": {"feature": {"num_classes": 17, "names": ["NOUN", "PUNCT", "ADP", "NUM", "SYM", "SCONJ", "ADJ", "PART", "DET", "CCONJ", "PROPN", "PRON", "X", "ADV", "INTJ", "VERB", "AUX"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}, "ner_tags": {"feature": {"num_classes": 19, "names": ["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-GPE_LOC", "I-GPE_LOC", "B-PROD", "I-PROD", "B-LOC", "I-LOC", "B-GPE_ORG", "I-GPE_ORG", "B-DRV", "I-DRV", "B-EVT", "I-EVT", "B-MISC", "I-MISC"], "names_file": null, "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "norne", "config_name": "combined", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 20104393, "num_examples": 29870, "dataset_name": "norne"}, "validation": {"name": "validation", "num_bytes": 2779723, "num_examples": 4300, "dataset_name": "norne"}, "test": {"name": "test", "num_bytes": 2257594, "num_examples": 3450, "dataset_name": "norne"}}, "download_checksums": {"https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nob/no_bokmaal-ud-train.conllu": {"num_bytes": 16437262, "checksum": "b17efd70034071f65ba5e3a15bc15f9a597f4c1dd3febb2ffec964906a9c1a98"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nob/no_bokmaal-ud-dev.conllu": {"num_bytes": 2453504, "checksum": "dba752ca6dc0c628f7cf12e9131b2627be0dff082bd96311bafce40590c46f9c"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nob/no_bokmaal-ud-test.conllu": {"num_bytes": 2018475, "checksum": "ace6fa65758541333e6a64210fa8466145e024cbbab18a156e8757c8b21c103b"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nno/no_nynorsk-ud-train.conllu": {"num_bytes": 16444176, "checksum": "589564c68ab0763c2574ad90ea8928f029144c966e4af064e59a0865c53c5ef2"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nno/no_nynorsk-ud-dev.conllu": {"num_bytes": 2096713, "checksum": "6519a00c0ddc4f8ef2605d7c5326adcafb2dfa2df439e281c95e1a0ef218b928"}, "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/nno/no_nynorsk-ud-test.conllu": {"num_bytes": 1668364, "checksum": "6b99cafd7019ed6d1eea1b51a0707df89cad597fe588b5987b9f278ffd87588c"}}, "download_size": 41118494, "post_processing_size": null, "dataset_size": 25141710, "size_in_bytes": 66260204}}
dummy/bokmaal/1.0.0/dummy_data.zip ADDED
Binary file (2.22 kB). View file
 
dummy/bokmaal/1.0.0/dummy_data.zip.lock ADDED
File without changes
dummy/combined/1.0.0/dummy_data.zip ADDED
Binary file (4.05 kB). View file
 
dummy/combined/1.0.0/dummy_data.zip.lock ADDED
File without changes
dummy/nynorsk/1.0.0/dummy_data.zip ADDED
Binary file (2.06 kB). View file
 
dummy/nynorsk/1.0.0/dummy_data.zip.lock ADDED
File without changes
norne.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2021 National Library of Norway.
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
+ """NorNE: Annotating Named Entities for Norwegian."""
18
+
19
+ try:
20
+ import conllu
21
+ except ImportError:
22
+ import sys
23
+
24
+ print("Please, 'pip install conllu' to use the NorNE dataset", file=sys.stderr)
25
+
26
+ import datasets
27
+
28
+
29
+ _CITATION = """\
30
+ @inproceedings{johansen2019ner,
31
+ title={NorNE: Annotating Named Entities for Norwegian},
32
+ author={Fredrik Jørgensen, Tobias Aasmoe, Anne-Stine Ruud Husevåg,
33
+ Lilja Øvrelid, and Erik Velldal},
34
+ booktitle={LREC 2020},
35
+ year={2020},
36
+ url={https://arxiv.org/abs/1911.12146}
37
+ }
38
+ """
39
+
40
+ _DESCRIPTION = """\
41
+ NorNE is a manually annotated
42
+ corpus of named entities which extends the annotation of the existing
43
+ Norwegian Dependency Treebank. Comprising both of the official standards of
44
+ written Norwegian (Bokmål and Nynorsk), the corpus contains around 600,000
45
+ tokens and annotates a rich set of entity types including persons,
46
+ organizations, locations, geo-political entities, products, and events,
47
+ in addition to a class corresponding to nominals derived from names.
48
+ """
49
+
50
+ _HOMEPAGE = "https://github.com/ltgoslo/norne"
51
+
52
+ _URL = "https://raw.githubusercontent.com/ltgoslo/norne/master/ud/"
53
+ _BOKMAAL_TRAIN = "nob/no_bokmaal-ud-train.conllu"
54
+ _BOKMAAL_DEV = "nob/no_bokmaal-ud-dev.conllu"
55
+ _BOKMAAL_TEST = "nob/no_bokmaal-ud-test.conllu"
56
+ _NYNORSK_TRAIN = "nno/no_nynorsk-ud-train.conllu"
57
+ _NYNORSK_DEV = "nno/no_nynorsk-ud-dev.conllu"
58
+ _NYNORSK_TEST = "nno/no_nynorsk-ud-test.conllu"
59
+
60
+
61
+ class NorneConfig(datasets.BuilderConfig):
62
+ """BuilderConfig for NorNE."""
63
+
64
+ def __init__(self, **kwargs):
65
+ """BuilderConfig for NorNE.
66
+
67
+ Args:
68
+ **kwargs: keyword arguments forwarded to super.
69
+ """
70
+ super(NorneConfig, self).__init__(**kwargs)
71
+
72
+
73
+ class Norne(datasets.GeneratorBasedBuilder):
74
+ """NorNE dataset."""
75
+
76
+ BUILDER_CONFIGS = [
77
+ NorneConfig(name="bokmaal", version=datasets.Version("1.0.0"), description="NorNE bokmaal dataset"),
78
+ NorneConfig(name="nynorsk", version=datasets.Version("1.0.0"), description="NorNE nynorsk dataset"),
79
+ NorneConfig(
80
+ name="combined", version=datasets.Version("1.0.0"), description="NorNE bokmaal and nynorsk dataset"
81
+ ),
82
+ ]
83
+
84
+ def _info(self):
85
+ return datasets.DatasetInfo(
86
+ description=_DESCRIPTION,
87
+ features=datasets.Features(
88
+ {
89
+ "idx": datasets.Value("string"),
90
+ "lang": datasets.Value("string"),
91
+ "text": datasets.Value("string"),
92
+ "tokens": datasets.Sequence(datasets.Value("string")),
93
+ "lemmas": datasets.Sequence(datasets.Value("string")),
94
+ "pos_tags": datasets.Sequence(
95
+ datasets.features.ClassLabel(
96
+ names=[
97
+ "NOUN",
98
+ "PUNCT",
99
+ "ADP",
100
+ "NUM",
101
+ "SYM",
102
+ "SCONJ",
103
+ "ADJ",
104
+ "PART",
105
+ "DET",
106
+ "CCONJ",
107
+ "PROPN",
108
+ "PRON",
109
+ "X",
110
+ "ADV",
111
+ "INTJ",
112
+ "VERB",
113
+ "AUX",
114
+ ]
115
+ )
116
+ ),
117
+ "ner_tags": datasets.Sequence(
118
+ datasets.features.ClassLabel(
119
+ names=[
120
+ "O",
121
+ "B-PER",
122
+ "I-PER",
123
+ "B-ORG",
124
+ "I-ORG",
125
+ "B-GPE_LOC",
126
+ "I-GPE_LOC",
127
+ "B-PROD",
128
+ "I-PROD",
129
+ "B-LOC",
130
+ "I-LOC",
131
+ "B-GPE_ORG",
132
+ "I-GPE_ORG",
133
+ "B-DRV",
134
+ "I-DRV",
135
+ "B-EVT",
136
+ "I-EVT",
137
+ "B-MISC",
138
+ "I-MISC",
139
+ ]
140
+ )
141
+ ),
142
+ }
143
+ ),
144
+ supervised_keys=None,
145
+ homepage=_HOMEPAGE,
146
+ citation=_CITATION,
147
+ )
148
+
149
+ def _split_generators(self, dl_manager):
150
+ """Returns SplitGenerators."""
151
+ train_filepaths = []
152
+ dev_filepaths = []
153
+ test_filepaths = []
154
+ langs = []
155
+ if self.config.name in ("bokmaal", "combined"):
156
+ downloaded_files = dl_manager.download_and_extract(
157
+ {
158
+ "train": f"{_URL}{_BOKMAAL_TRAIN}",
159
+ "dev": f"{_URL}{_BOKMAAL_DEV}",
160
+ "test": f"{_URL}{_BOKMAAL_TEST}",
161
+ }
162
+ )
163
+ train_filepaths.append(downloaded_files["train"])
164
+ dev_filepaths.append(downloaded_files["dev"])
165
+ test_filepaths.append(downloaded_files["test"])
166
+ langs.append("bokmaal")
167
+ if self.config.name in ("nynorsk", "combined"):
168
+ downloaded_files = dl_manager.download_and_extract(
169
+ {
170
+ "train": f"{_URL}{_NYNORSK_TRAIN}",
171
+ "dev": f"{_URL}{_NYNORSK_DEV}",
172
+ "test": f"{_URL}{_NYNORSK_TEST}",
173
+ }
174
+ )
175
+ train_filepaths.append(downloaded_files["train"])
176
+ dev_filepaths.append(downloaded_files["dev"])
177
+ test_filepaths.append(downloaded_files["test"])
178
+ langs.append("nynorsk")
179
+ return [
180
+ datasets.SplitGenerator(
181
+ name=datasets.Split.TRAIN, gen_kwargs={"filepaths": train_filepaths, "langs": langs}
182
+ ),
183
+ datasets.SplitGenerator(
184
+ name=datasets.Split.VALIDATION, gen_kwargs={"filepaths": dev_filepaths, "langs": langs}
185
+ ),
186
+ datasets.SplitGenerator(
187
+ name=datasets.Split.TEST, gen_kwargs={"filepaths": test_filepaths, "langs": langs}
188
+ ),
189
+ ]
190
+
191
+ def _generate_examples(self, filepaths, langs):
192
+ idx = 0
193
+ for filepath, lang in zip(filepaths, langs):
194
+ with open(filepath, "r", encoding="utf-8") as data_file:
195
+ tokens = list(conllu.parse_incr(data_file))
196
+ for sent in tokens:
197
+ yield idx, {
198
+ "idx": sent.metadata["sent_id"],
199
+ "lang": lang,
200
+ "text": sent.metadata["text"],
201
+ "tokens": [token["form"] for token in sent],
202
+ "lemmas": [token["lemma"] for token in sent],
203
+ "pos_tags": [token["upos"] for token in sent],
204
+ "ner_tags": [token["misc"].get("name", "O") for token in sent],
205
+ }
206
+ idx += 1
norne.py.lock ADDED
File without changes