iluvvatar commited on
Commit
f8bf13a
·
1 Parent(s): 1d5c64e
Files changed (7) hide show
  1. NEREL.py +108 -0
  2. README.md +92 -0
  3. data/dev.jsonl +0 -0
  4. data/test.jsonl +0 -0
  5. data/train.jsonl +0 -0
  6. ent_types.jsonl +29 -0
  7. rel_types.jsonl +49 -0
NEREL.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import json
3
+
4
+ _NAME = 'NEREL'
5
+ _CITATION = '''
6
+ @article{loukachevitch2021nerel,
7
+ title={NEREL: A Russian Dataset with Nested Named Entities, Relations and Events},
8
+ author={Loukachevitch, Natalia and Artemova, Ekaterina and Batura, Tatiana and Braslavski, Pavel and Denisov, Ilia and Ivanov, Vladimir and Manandhar, Suresh and Pugachev, Alexander and Tutubalina, Elena},
9
+ journal={arXiv preprint arXiv:2108.13112},
10
+ year={2021}
11
+ }
12
+ '''.strip()
13
+ _DESCRIPTION = 'A Russian Dataset with Nested Named Entities, Relations and Events'
14
+ _HOMEPAGE = 'https://doi.org/10.48550/arXiv.2108.13112'
15
+ _VERSION = '1.1.0'
16
+
17
+
18
+ class NERELBuilder(datasets.GeneratorBasedBuilder):
19
+ _DATA_URLS = {
20
+ 'train': 'data/train.jsonl',
21
+ 'test': f'data/test.jsonl',
22
+ 'dev': f'data/dev.jsonl',
23
+ }
24
+ _ENT_TYPES_URLS = {
25
+ 'ent_types': 'ent_types.jsonl'
26
+ }
27
+ _REL_TYPES_URLS = {
28
+ 'rel_types': 'rel_types.jsonl'
29
+ }
30
+ VERSION = datasets.Version(_VERSION)
31
+ BUILDER_CONFIGS = [
32
+ datasets.BuilderConfig('data',
33
+ version=VERSION,
34
+ description='Data'),
35
+ datasets.BuilderConfig('ent_types',
36
+ version=VERSION,
37
+ description='Entity types list'),
38
+ datasets.BuilderConfig('rel_types',
39
+ version=VERSION,
40
+ description='Relation types list')
41
+ ]
42
+ DEFAULT_CONFIG_NAME = 'data'
43
+
44
+ def _info(self) -> datasets.DatasetInfo:
45
+ if self.config.name == 'data':
46
+ features = datasets.Features({
47
+ 'id': datasets.Value('int32'),
48
+ 'text': datasets.Value('string'),
49
+ 'entities': datasets.Sequence(datasets.Value('string')),
50
+ 'relations': datasets.Sequence(datasets.Value('string')),
51
+ 'links': datasets.Sequence(datasets.Value('string'))
52
+ })
53
+ elif self.config.name == 'ent_types':
54
+ features = datasets.Features({
55
+ 'type': datasets.Value('string'),
56
+ 'link': datasets.Value('string')
57
+ })
58
+ else:
59
+ features = datasets.Features({
60
+ 'type': datasets.Value('string'),
61
+ 'arg1': datasets.Sequence(datasets.Value('string')),
62
+ 'arg2': datasets.Sequence(datasets.Value('string')),
63
+ })
64
+ return datasets.DatasetInfo(
65
+ description=_DESCRIPTION,
66
+ features=features,
67
+ homepage=_HOMEPAGE,
68
+ citation=_CITATION
69
+ )
70
+
71
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
72
+ if self.config.name == 'data':
73
+ files = dl_manager.download(self._DATA_URLS)
74
+ return [
75
+ datasets.SplitGenerator(
76
+ name=datasets.Split.TRAIN,
77
+ gen_kwargs={'filepath': files['train']},
78
+ ),
79
+ datasets.SplitGenerator(
80
+ name=datasets.Split.TEST,
81
+ gen_kwargs={'filepath': files['test']},
82
+ ),
83
+ datasets.SplitGenerator(
84
+ name='dev',
85
+ gen_kwargs={'filepath': files['dev']},
86
+ ),
87
+ ]
88
+ elif self.config.name == 'ent_types':
89
+ files = dl_manager.download(self._ENT_TYPES_URLS)
90
+ return [
91
+ datasets.SplitGenerator(
92
+ name='ent_types',
93
+ gen_kwargs={'filepath': files['ent_types']},
94
+ )
95
+ ]
96
+ else:
97
+ files = dl_manager.download(self._REL_TYPES_URLS)
98
+ return [
99
+ datasets.SplitGenerator(
100
+ name='rel_types',
101
+ gen_kwargs={'filepath': files['rel_types']},
102
+ )
103
+ ]
104
+
105
+ def _generate_examples(self, filepath):
106
+ with open(filepath, encoding='utf-8') as f:
107
+ for i, line in enumerate(f):
108
+ yield i, json.loads(line)
README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ languages:
3
+ - ru
4
+ multilinguality:
5
+ - monolingual
6
+ pretty_name: NEREL
7
+ task_categories:
8
+ - structure-prediction
9
+ task_ids:
10
+ - named-entity-recognition
11
+ ---
12
+
13
+ # NEREL dataset
14
+
15
+ ## Table of Contents
16
+ - [Dataset Description](#dataset-description)
17
+ - [Dataset Structure](#dataset-structure)
18
+ - [Citation Information](#citation-information)
19
+ - [Contacts](#contacts)
20
+
21
+ ## Dataset Description
22
+ NEREL dataset (https://doi.org/10.48550/arXiv.2108.13112) is
23
+ a Russian dataset for named entity recognition and relation extraction.
24
+ NEREL is significantly larger than existing Russian datasets:
25
+ to date it contains 56K annotated named entities and 39K annotated relations.
26
+ Its important difference from previous datasets is annotation of nested named
27
+ entities, as well as relations within nested entities and at the discourse
28
+ level. NEREL can facilitate development of novel models that can extract
29
+ relations between nested named entities, as well as relations on both sentence
30
+ and document levels. NEREL also contains the annotation of events involving
31
+ named entities and their roles in the events.
32
+
33
+ You can see full entity types list in a subset "ent_types"
34
+ and full list of relation types in a subset "rel_types".
35
+
36
+ ## Dataset Structure
37
+ There are three "configs" or "subsets" of the dataset.
38
+
39
+ Using
40
+ `load_dataset('MalakhovIlya/NEREL', 'ent_types')['ent_types']`
41
+ you can download list of entity types (
42
+ Dataset({features: ['type', 'link']})
43
+ ) where "link" is a knowledge base name used in entity linking task.
44
+
45
+ Using
46
+ `load_dataset('MalakhovIlya/NEREL', 'rel_types')['rel_types']`
47
+ you can download list of entity types (
48
+ Dataset({features: ['type', 'arg1', 'arg2']})
49
+ ) where "arg1" and "arg2" are lists of entity types that can take part in such
50
+ "type" of relation. \<ENTITY> stands for any type.
51
+
52
+ Using
53
+ `load_dataset('MalakhovIlya/NEREL', 'data')` or `load_dataset('MalakhovIlya/NEREL')`
54
+ you can download the data itself,
55
+ DatasetDict with 3 splits: "train", "test" and "dev".
56
+ Each of them contains text document with annotated entities, relations and
57
+ links.
58
+
59
+ "entities" are used in named-entity recognition task (see https://en.wikipedia.org/wiki/Named-entity_recognition).
60
+ "relations" are used in relationship extraction task (see https://en.wikipedia.org/wiki/Relationship_extraction).
61
+ "links" are used in entity linking task (see https://en.wikipedia.org/wiki/Entity_linking)
62
+
63
+ Each entity is represented by a string of the following format:
64
+ `"<id>\t<type> <start> <stop>\t<text>"`, where
65
+ `<id>` is an entity id,
66
+ `<type>` is one of entity types,
67
+ `<start>` is a position of the first symbol of entity in text,
68
+ `<stop>` is the last symbol position in text +1.
69
+
70
+ Each relation is represented by a string of the following format:
71
+ `"<id>\t<type> Arg1:<arg1_id> Arg2:<arg2_id>"`, where
72
+ `<id>` is a relation id,
73
+ `<arg1_id>` and `<arg2_id>` are entity ids.
74
+
75
+ Each link is represented by a string of the following format:
76
+ `"<id>\tReference <ent_id> <link>\t<text>"`, where
77
+ `<id>` is a link id,
78
+ `<ent_id>` is an entity id,
79
+ `<link>` is a reference to knowledge base entity (example: "Wikidata:Q1879675" if link exists, else "Wikidata:NULL"),
80
+ `<text>` is a name of entity in knowledge base if link exists, else empty string.
81
+
82
+ ## Citation Information
83
+ @article{loukachevitch2021nerel,
84
+ title={NEREL: A Russian Dataset with Nested Named Entities, Relations and Events},
85
+ author={Loukachevitch, Natalia and Artemova, Ekaterina and Batura, Tatiana and Braslavski, Pavel and Denisov, Ilia and Ivanov, Vladimir and Manandhar, Suresh and Pugachev, Alexander and Tutubalina, Elena},
86
+ journal={arXiv preprint arXiv:2108.13112},
87
+ year={2021}
88
+ }
89
+
90
+ ## Contacts
91
+ Malakhov Ilya
92
+ Telegram - https://t.me/noname_4710
data/dev.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
ent_types.jsonl ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"type": "AGE", "link": ""}
2
+ {"type": "AWARD", "link": "<NORM>:Wikidata"}
3
+ {"type": "CITY", "link": "<NORM>:Wikidata"}
4
+ {"type": "COUNTRY", "link": "<NORM>:Wikidata"}
5
+ {"type": "CRIME", "link": ""}
6
+ {"type": "DATE", "link": ""}
7
+ {"type": "DISEASE", "link": "<NORM>:Wikidata"}
8
+ {"type": "DISTRICT", "link": "<NORM>:Wikidata"}
9
+ {"type": "EVENT", "link": "<NORM>:Wikidata"}
10
+ {"type": "FACILITY", "link": "<NORM>:Wikidata"}
11
+ {"type": "FAMILY", "link": ""}
12
+ {"type": "IDEOLOGY", "link": "<NORM>:Wikidata"}
13
+ {"type": "LANGUAGE", "link": "<NORM>:Wikidata"}
14
+ {"type": "LAW", "link": "<NORM>:Wikidata"}
15
+ {"type": "LOCATION", "link": "<NORM>:Wikidata"}
16
+ {"type": "MONEY", "link": ""}
17
+ {"type": "NATIONALITY", "link": "<NORM>:Wikidata"}
18
+ {"type": "NUMBER", "link": ""}
19
+ {"type": "ORDINAL", "link": ""}
20
+ {"type": "ORGANIZATION", "link": "<NORM>:Wikidata"}
21
+ {"type": "PENALTY", "link": ""}
22
+ {"type": "PERCENT", "link": ""}
23
+ {"type": "PERSON", "link": "<NORM>:Wikidata"}
24
+ {"type": "PRODUCT", "link": "<NORM>:Wikidata"}
25
+ {"type": "PROFESSION", "link": "<NORM>:Wikidata"}
26
+ {"type": "RELIGION", "link": "<NORM>:Wikidata"}
27
+ {"type": "STATE_OR_PROVINCE", "link": "<NORM>:Wikidata"}
28
+ {"type": "TIME", "link": ""}
29
+ {"type": "WORK_OF_ART", "link": "<NORM>:Wikidata"}
rel_types.jsonl ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"type": "ABBREVIATION", "arg1": ["<ENTITY>"], "arg2": ["<ENTITY>"]}
2
+ {"type": "KNOWS", "arg1": ["PERSON", "PROFESSION"], "arg2": ["<ENTITY>"]}
3
+ {"type": "AGE_IS", "arg1": ["<ENTITY>"], "arg2": ["AGE"]}
4
+ {"type": "AGE_DIED_AT", "arg1": ["PERSON", "PROFESSION"], "arg2": ["AGE"]}
5
+ {"type": "ALTERNATIVE_NAME", "arg1": ["<ENTITY>"], "arg2": ["<ENTITY>"]}
6
+ {"type": "AWARDED_WITH", "arg1": ["PERSON", "PROFESSION", "ORGANIZATION", "WORK_OF_ART", "NATIONALITY"], "arg2": ["AWARD"]}
7
+ {"type": "PLACE_OF_BIRTH", "arg1": ["PERSON", "PROFESSION"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "LOCATION", "STATE_OR_PROVINCE"]}
8
+ {"type": "CAUSE_OF_DEATH", "arg1": ["PERSON", "PROFESSION", "NATIONALITY"], "arg2": ["DISEASE", "EVENT"]}
9
+ {"type": "DATE_DEFUNCT_IN", "arg1": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "EVENT", "ORGANIZATION", "STATE_OR_PROVINCE", "WORK_OF_ART"], "arg2": ["DATE"]}
10
+ {"type": "DATE_FOUNDED_IN", "arg1": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "EVENT", "LOCATION", "ORGANIZATION", "STATE_OR_PROVINCE", "WORK_OF_ART"], "arg2": ["DATE"]}
11
+ {"type": "DATE_OF_BIRTH", "arg1": ["PERSON", "PROFESSION"], "arg2": ["DATE"]}
12
+ {"type": "DATE_OF_CREATION", "arg1": ["WORK_OF_ART", "LAW", "AWARD", "PRODUCT"], "arg2": ["DATE"]}
13
+ {"type": "DATE_OF_DEATH", "arg1": ["PERSON", "PROFESSION", "NATIONALITY"], "arg2": ["DATE"]}
14
+ {"type": "POINT_IN_TIME", "arg1": ["EVENT", "PENALTY", "CRIME", "WORK_OF_ART", "AWARD", "PRODUCT"], "arg2": ["DATE", "TIME"]}
15
+ {"type": "PLACE_OF_DEATH", "arg1": ["PERSON", "PROFESSION", "NATIONALITY"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "LOCATION", "STATE_OR_PROVINCE"]}
16
+ {"type": "FOUNDED_BY", "arg1": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "EVENT", "LOCATION", "ORGANIZATION", "STATE_OR_PROVINCE", "PROFESSION"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "EVENT", "LOCATION", "ORGANIZATION", "PERSON", "PROFESSION", "STATE_OR_PROVINCE", "FAMILY"]}
17
+ {"type": "HEADQUARTERED_IN", "arg1": ["ORGANIZATION"], "arg2": ["LOCATION", "CITY", "COUNTRY", "DISTRICT", "STATE_OR_PROVINCE", "FACILITY"]}
18
+ {"type": "IDEOLOGY_OF", "arg1": ["PERSON", "ORGANIZATION", "PROFESSION", "COUNTRY", "FACILITY", "NATIONALITY", "EVENT"], "arg2": ["IDEOLOGY"]}
19
+ {"type": "LOCATED_IN", "arg1": ["PERSON", "PROFESSION", "CITY", "COUNTRY", "DISTRICT", "FACILITY", "LOCATION", "ORGANIZATION", "PRODUCT", "STATE_OR_PROVINCE", "WORK_OF_ART"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "LOCATION", "ORGANIZATION", "STATE_OR_PROVINCE"]}
20
+ {"type": "SPOUSE", "arg1": ["PERSON", "PROFESSION"], "arg2": ["PERSON", "PROFESSION"]}
21
+ {"type": "MEDICAL_CONDITION", "arg1": ["PERSON", "PROFESSION"], "arg2": ["DISEASE"]}
22
+ {"type": "MEMBER_OF", "arg1": ["PERSON", "PROFESSION", "ORGANIZATION", "COUNTRY"], "arg2": ["ORGANIZATION", "IDEOLOGY", "COUNTRY", "FAMILY"]}
23
+ {"type": "ORGANIZES", "arg1": ["CITY", "COUNTRY", "DISTRICT", "ORGANIZATION", "PERSON", "PROFESSION", "STATE_OR_PROVINCE"], "arg2": ["EVENT"]}
24
+ {"type": "ORIGINS_FROM", "arg1": ["<ENTITY>"], "arg2": ["<ENTITY>"]}
25
+ {"type": "OWNER_OF", "arg1": ["<ENTITY>"], "arg2": ["<ENTITY>"]}
26
+ {"type": "PARENT_OF", "arg1": ["PERSON", "PROFESSION", "NATIONALITY"], "arg2": ["PERSON", "PROFESSION", "NATIONALITY"]}
27
+ {"type": "PLACE_RESIDES_IN", "arg1": ["PERSON", "PROFESSION", "NATIONALITY", "FAMILY"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "LOCATION", "STATE_OR_PROVINCE"]}
28
+ {"type": "PRICE_OF", "arg1": ["<ENTITY>"], "arg2": ["MONEY"]}
29
+ {"type": "PRODUCES", "arg1": ["CITY", "COUNTRY", "DISTRICT", "ORGANIZATION", "PERSON", "PROFESSION", "STATE_OR_PROVINCE"], "arg2": ["<ENTITY>"]}
30
+ {"type": "RELATIVE", "arg1": ["<ENTITY>"], "arg2": ["<ENTITY>"]}
31
+ {"type": "RELIGION_OF", "arg1": ["PERSON", "ORGANIZATION", "PROFESSION", "COUNTRY", "FACILITY", "NATIONALITY", "EVENT"], "arg2": ["RELIGION"]}
32
+ {"type": "SCHOOLS_ATTENDED", "arg1": ["PERSON", "PROFESSION", "NATIONALITY"], "arg2": ["ORGANIZATION"]}
33
+ {"type": "SIBLING", "arg1": ["PERSON", "PROFESSION"], "arg2": ["PERSON", "PROFESSION"]}
34
+ {"type": "SUBEVENT_OF", "arg1": ["EVENT"], "arg2": ["EVENT"]}
35
+ {"type": "SUBORDINATE_OF", "arg1": ["PERSON", "PROFESSION"], "arg2": ["PERSON", "PROFESSION"]}
36
+ {"type": "TAKES_PLACE_IN", "arg1": ["EVENT", "CRIME", "PENALTY"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "ORGANIZATION", "STATE_OR_PROVINCE", "FACILITY", "LOCATION"]}
37
+ {"type": "WORKPLACE", "arg1": ["PERSON", "PROFESSION"], "arg2": ["CITY", "COUNTRY", "DISTRICT", "FACILITY", "EVENT", "LOCATION", "IDEOLOGY", "ORGANIZATION", "STATE_OR_PROVINCE"]}
38
+ {"type": "WORKS_AS", "arg1": ["PERSON"], "arg2": ["PROFESSION"]}
39
+ {"type": "START_TIME", "arg1": ["EVENT", "PENALTY", "CRIME", "WORK_OF_ART"], "arg2": ["DATE", "TIME"]}
40
+ {"type": "END_TIME", "arg1": ["EVENT", "PENALTY", "CRIME", "WORK_OF_ART"], "arg2": ["DATE", "TIME"]}
41
+ {"type": "CONVICTED_OF", "arg1": ["PERSON", "PROFESSION", "ORGANIZATION", "FAMILY", "NATIONALITY", "COUNTRY"], "arg2": ["CRIME"]}
42
+ {"type": "PENALIZED_AS", "arg1": ["PERSON", "PROFESSION", "ORGANIZATION", "FAMILY", "NATIONALITY", "COUNTRY"], "arg2": ["PENALTY"]}
43
+ {"type": "PART_OF", "arg1": ["ORGANIZATION", "WORK_OF_ART", "LAW", "FACILITY", "PRODUCT", "AWARD"], "arg2": ["ORGANIZATION", "WORK_OF_ART", "LAW", "FACILITY", "PRODUCT", "AWARD"]}
44
+ {"type": "HAS_CAUSE", "arg1": ["EVENT", "CRIME", "PENALTY", "AWARD", "DISEASE"], "arg2": ["EVENT", "CRIME", "PENALTY", "LAW", "DISEASE"]}
45
+ {"type": "AGENT", "arg1": ["PERSON", "PROFESSION", "ORGANIZATION", "CITY", "COUNTRY", "STATE_OR_PROVINCE", "FAMILY", "NATIONALITY", "IDEOLOGY", "RELIGION"], "arg2": ["EVENT"]}
46
+ {"type": "PARTICIPANT_IN", "arg1": ["PERSON", "PROFESSION", "ORGANIZATION", "CITY", "COUNTRY", "STATE_OR_PROVINCE", "FACILITY", "AWARD", "WORK_OF_ART", "FAMILY", "NATIONALITY", "IDEOLOGY", "RELIGION", "NATIONALITY"], "arg2": ["EVENT", "WORK_OF_ART", "CRIME", "PENALTY"]}
47
+ {"type": "INANIMATE_INVOLVED", "arg1": ["PERSON", "PRODUCT", "FACILITY", "AWARD", "WORK_OF_ART", "LAW", "MONEY"], "arg2": ["EVENT", "WORK_OF_ART", "CRIME", "PENALTY"]}
48
+ {"type": "EXPENDITURE", "arg1": ["PERSON", "PROFESSION", "CITY", "COUNTRY", "DISTRICT", "ORGANIZATION", "FAMILY", "STATE_OR_PROVINCE", "NATIONALITY"], "arg2": ["MONEY"]}
49
+ {"type": "INCOME", "arg1": ["PERSON", "PROFESSION", "CITY", "COUNTRY", "DISTRICT", "ORGANIZATION", "FAMILY", "STATE_OR_PROVINCE", "NATIONALITY"], "arg2": ["MONEY"]}