Tamás Ficsor commited on
Commit
266d93d
1 Parent(s): 990dd05

SzegedNER Dataset

Browse files
README.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language:
5
+ - hu
6
+ language_creators:
7
+ - other
8
+ license: []
9
+ multilinguality:
10
+ - monolingual
11
+ paperswithcode_id: null
12
+ pretty_name: SzegedNER
13
+ size_categories:
14
+ - 1K<n<10K
15
+ source_datasets:
16
+ - original
17
+ tags:
18
+ - hungarian
19
+ - szeged
20
+ - ner
21
+ task_categories:
22
+ - token-classification
23
+ task_ids:
24
+ - named-entity-recognition
25
+ ---
26
+
27
+ # Introduction
28
+
29
+ The recognition and classification of proper nouns and names in plain text is of key importance in Natural Language Processing (NLP) as it has a beneficial effect on the performance of various types of applications, including Information Extraction, Machine Translation, Syntactic Parsing/Chunking, etc.
30
+
31
+ ## Corpus of Business Newswire Texts (business)
32
+
33
+ The Named Entity Corpus for Hungarian is a subcorpus of the Szeged Treebank, which contains full syntactic annotations done manually by linguist experts. A significant part of these texts has been annotated with Named Entity class labels in line with the annotation standards used on the CoNLL-2003 shared task.
34
+
35
+ Statistical data on Named Entities occurring in the corpus:
36
+
37
+ ```
38
+ | tokens | phrases
39
+ ------ | ------ | -------
40
+ non NE | 200067 |
41
+ PER | 1921 | 982
42
+ ORG | 20433 | 10533
43
+ LOC | 1501 | 1294
44
+ MISC | 2041 | 1662
45
+ ```
46
+
47
+ ### Reference
48
+
49
+ > György Szarvas, Richárd Farkas, László Felföldi, András Kocsor, János Csirik: Highly accurate Named Entity corpus for Hungarian. International Conference on Language Resources and Evaluation 2006, Genova (Italy)
50
+
51
+ ## Criminal NE corpus (criminal)
52
+
53
+ The Hungarian National Corpus and its Heti Világgazdaság (HVG) subcorpus provided the basis for corpus text selection: articles related to the topic of financially liable offences were selected and annotated for the categories person, organization, location and miscellaneous.
54
+ There are two annotated versions of the corpus. When preparing the tag-for-meaning annotation, our linguists took into consideration the context in which the Named Entity under investigation occurred, thus, it was not the primary sense of the Named Entity that determined the tag (e.g. Manchester=LOC) but its contextual reference (e.g. Manchester won the Premier League=ORG). As for tag-for-tag annotation, these cases were not differentiated: tags were always given on the basis of the primary sense.
55
+
56
+ Statistical data on Named Entities occurring in the corpus:
57
+
58
+ ```
59
+ | tag-for-meaning | tag-for-tag
60
+ ------ | --------------- | -----------
61
+ non NE | 200067 |
62
+ PER | 8101 | 8121
63
+ ORG | 8782 | 9480
64
+ LOC | 5049 | 5391
65
+ MISC | 1917 | 854
66
+ ```
67
+
68
+ ## Metadata
69
+
70
+ dataset_info:
71
+ - config_name: business
72
+ features:
73
+ - name: id
74
+ dtype: string
75
+ - name: tokens
76
+ sequence: string
77
+ - name: ner_tags
78
+ sequence:
79
+ class_label:
80
+ names:
81
+ 0: O
82
+ 1: B-PER
83
+ 2: I-PER
84
+ 3: B-ORG
85
+ 4: I-ORG
86
+ 5: B-LOC
87
+ 6: I-LOC
88
+ 7: B-MISC
89
+ 8: I-MISC
90
+ - name: document_id
91
+ dtype: string
92
+ - name: sentence_id
93
+ dtype: string
94
+ splits:
95
+ - name: original
96
+ num_bytes: 4452207
97
+ num_examples: 9573
98
+ - name: test
99
+ num_bytes: 856798
100
+ num_examples: 1915
101
+ - name: train
102
+ num_bytes: 3171931
103
+ num_examples: 6701
104
+ - name: validation
105
+ num_bytes: 423478
106
+ num_examples: 957
107
+ download_size: 0
108
+ dataset_size: 8904414
109
+ - config_name: criminal
110
+ features:
111
+ - name: id
112
+ dtype: string
113
+ - name: tokens
114
+ sequence: string
115
+ - name: ner_tags
116
+ sequence:
117
+ class_label:
118
+ names:
119
+ 0: O
120
+ 1: B-PER
121
+ 2: I-PER
122
+ 3: B-ORG
123
+ 4: I-ORG
124
+ 5: B-LOC
125
+ 6: I-LOC
126
+ 7: B-MISC
127
+ 8: I-MISC
128
+ - name: document_id
129
+ dtype: string
130
+ - name: sentence_id
131
+ dtype: string
132
+ splits:
133
+ - name: original
134
+ num_bytes: 2807970
135
+ num_examples: 5375
136
+ - name: test
137
+ num_bytes: 520959
138
+ num_examples: 1089
139
+ - name: train
140
+ num_bytes: 1989662
141
+ num_examples: 3760
142
+ - name: validation
143
+ num_bytes: 297349
144
+ num_examples: 526
145
+ download_size: 0
146
+ dataset_size: 5615940
147
+
SzegedNER.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import BuilderConfig, Version, GeneratorBasedBuilder, DatasetInfo, Features, Value, \
2
+ Sequence, ClassLabel, DownloadManager, SplitGenerator, Split
3
+ import datasets
4
+ import os
5
+ import textwrap
6
+ import csv
7
+ from ast import literal_eval
8
+
9
+
10
+ _DESCRIPTION = """
11
+ The recognition and classification of proper nouns and names in plain text is of key importance in Natural Language
12
+ Processing (NLP) as it has a beneficial effect on the performance of various types of applications, including
13
+ Information Extraction, Machine Translation, Syntactic Parsing/Chunking, etc."""
14
+ _CITATION = """"""
15
+ _FEATURES = Features(
16
+ {
17
+ "id": Value("int32"),
18
+ "tokens": Sequence(Value("string")),
19
+ "ner": Sequence(
20
+ ClassLabel(
21
+ names=[
22
+ "O",
23
+ "B-PER",
24
+ "I-PER",
25
+ "B-ORG",
26
+ "I-ORG",
27
+ "B-LOC",
28
+ "I-LOC",
29
+ "B-MISC",
30
+ "I-MISC",
31
+ ]
32
+ )
33
+ ),
34
+ "document_id": Value("int32"),
35
+ "sentence_id": Value("int32")
36
+ }
37
+ )
38
+
39
+
40
+ class SzegedNERConfig(BuilderConfig):
41
+ """BuilderConfig for SzegedNER."""
42
+
43
+ def __init__(
44
+ self,
45
+ features,
46
+ label_column,
47
+ data_dir,
48
+ citation,
49
+ url,
50
+ process_label=lambda x: x,
51
+ **kwargs,
52
+ ):
53
+ super(SzegedNERConfig, self).__init__(version=Version("1.0.0", ""), **kwargs)
54
+ self.features = features
55
+ self.label_column = label_column
56
+ self.data_dir = data_dir
57
+ self.citation = citation
58
+ self.url = url
59
+ self.process_label = process_label
60
+
61
+
62
+ class SzegedNER(GeneratorBasedBuilder):
63
+ """SzegedNER datasets."""
64
+
65
+ BUILDER_CONFIGS = [
66
+ SzegedNERConfig(
67
+ name="business",
68
+ description=textwrap.dedent(
69
+ """\
70
+ The Named Entity Corpus for Hungarian is a subcorpus of the Szeged Treebank, which contains full syntactic
71
+ annotations done manually by linguist experts. A significant part of these texts has been annotated with
72
+ Named Entity class labels in line with the annotation standards used on the CoNLL-2003 shared task."""
73
+ ),
74
+ features=_FEATURES,
75
+ label_column="ner_tags",
76
+ data_dir="data/business/",
77
+ citation=textwrap.dedent(_CITATION),
78
+ url="https://rgai.inf.u-szeged.hu/node/130"
79
+ ),
80
+ SzegedNERConfig(
81
+ name="criminal",
82
+ description=textwrap.dedent(
83
+ """\
84
+ The Hungarian National Corpus and its Heti Világgazdaság (HVG) subcorpus provided the basis for corpus text
85
+ selection: articles related to the topic of financially liable offences were selected and annotated for the
86
+ categories person, organization, location and miscellaneous. There are two annotated versions of the corpus.
87
+ When preparing the tag-for-meaning annotation, our linguists took into consideration the context in which
88
+ the Named Entity under investigation occurred, thus, it was not the primary sense of the Named Entity that
89
+ determined the tag (e.g. Manchester=LOC) but its contextual reference (e.g. Manchester won the Premier
90
+ League=ORG). As for tag-for-tag annotation, these cases were not differentiated: tags were always given on
91
+ the basis of the primary sense."""
92
+ ),
93
+ features=_FEATURES,
94
+ label_column="ner_tags",
95
+ data_dir="data/criminal/",
96
+ citation=textwrap.dedent(_CITATION),
97
+ url="https://rgai.inf.u-szeged.hu/node/130"
98
+ )
99
+ ]
100
+
101
+ def _info(self):
102
+ return DatasetInfo(
103
+ description=self.config.description,
104
+ features=self.config.features,
105
+ homepage=self.config.url,
106
+ citation=self.config.citation,
107
+ )
108
+
109
+ def _split_generators(self, dl_manager: DownloadManager):
110
+ url = f"{self.base_path}{self.config.data_dir}"
111
+
112
+ path = dl_manager.download({key: f"{url}{key}.csv" for key in ["train", "validation", "test", "all"]})
113
+ return [
114
+ SplitGenerator(
115
+ name=Split.TRAIN,
116
+ gen_kwargs={"split_key": "train", "data_file": path['train']},
117
+ ),
118
+ SplitGenerator(
119
+ name=Split.VALIDATION,
120
+ gen_kwargs={"split_key": "validation", "data_file": path['validation']},
121
+ ),
122
+ SplitGenerator(
123
+ name=Split.TEST,
124
+ gen_kwargs={"split_key": "test", "data_file": path['test']},
125
+ )
126
+ ]
127
+
128
+ def _generate_examples(self, data_file, split_key, **kwargs):
129
+ with open(data_file, encoding="utf8") as f:
130
+ reader = csv.DictReader(f, delimiter=",", quoting=csv.QUOTE_MINIMAL)
131
+ for n, row in enumerate(reader):
132
+ labels = literal_eval(row['ner'])
133
+ tokens = literal_eval(row['tokens'])
134
+ if len(labels) != len(tokens):
135
+ raise ValueError("Number of tokens and labels does not match")
136
+ yield n, {
137
+ "id": int(row['id']),
138
+ "tokens": tokens,
139
+ "ner": labels,
140
+ "document_id": int(row['document_id']),
141
+ "sentence_id": int(row['sentence_id'])
142
+ }
data/business/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:925a23ac30f7fb533490aae29b271b49e63b98e51feffb537b9584edd1b3546a
3
+ size 366898
data/business/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e2fe5d597f812254bf144c9e0f60585a104bec30129ca268b54f62241cf5d11
3
+ size 3228046
data/business/validation.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45fcb36de69c98b51ad58bfce099c58218bef06cff112beb2d46ba77b26b8b70
3
+ size 187647
data/criminal/test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dccc2c08e2a7f111b16863ce023d333aad532fac5873cebdcb3a1e63ff38437c
3
+ size 387511
data/criminal/train.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b1d50794cf3e18bec248ab934860e665db4c1be4070555172064d5736554208
3
+ size 1748329
data/criminal/validation.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3aea95adb9689c814e2706db52acf11fe61f0eca6a061b3a60db3b35755ac38
3
+ size 221219