albertvillanova HF staff commited on
Commit
49b2e1c
1 Parent(s): 269c168

Delete loading script

Browse files
Files changed (1) hide show
  1. euronews.py +0 -161
euronews.py DELETED
@@ -1,161 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 HuggingFace Datasets Authors.
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
- """Named Entity Recognition corpora for Dutch, French, German from Europeana Newspapers."""
18
-
19
- import datasets
20
-
21
-
22
- logger = datasets.logging.get_logger(__name__)
23
-
24
-
25
- _CITATION = """\
26
- @InProceedings{NEUDECKER16.110,
27
- author = {Clemens Neudecker},
28
- title = {An Open Corpus for Named Entity Recognition in Historic Newspapers},
29
- booktitle = {Proceedings of the Tenth International Conference on Language Resources and Evaluation (LREC 2016)},
30
- year = {2016},
31
- month = {may},
32
- date = {23-28},
33
- location = {Portorož, Slovenia},
34
- editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Sara Goggi and Marko Grobelnik and Bente Maegaard and Joseph Mariani and Helene Mazo and Asuncion Moreno and Jan Odijk and Stelios Piperidis},
35
- publisher = {European Language Resources Association (ELRA)},
36
- address = {Paris, France},
37
- isbn = {978-2-9517408-9-1},
38
- language = {english}
39
- }
40
- """
41
-
42
- _DESCRIPTION = """\
43
- The corpora comprise of files per data provider that are encoded in the IOB format (Ramshaw & Marcus, 1995). The IOB format is a simple text chunking format that divides texts into single tokens per line, and, separated by a whitespace, tags to mark named entities. The most commonly used categories for tags are PER (person), LOC (location) and ORG (organization). To mark named entities that span multiple tokens, the tags have a prefix of either B- (beginning of named entity) or I- (inside of named entity). O (outside of named entity) tags are used to mark tokens that are not a named entity.
44
- """
45
-
46
- _URL = "https://raw.githubusercontent.com/EuropeanaNewspapers/ner-corpora/master/"
47
- _FR_BNF = "enp_FR.bnf.bio/enp_FR.bnf.bio"
48
- _NL_KB = "enp_NL.kb.bio/enp_NL.kb.bio"
49
- _DE_SBB = "enp_DE.sbb.bio/enp_DE.sbb.bio"
50
- _DE_ONB = "enp_DE.onb.bio/enp_DE.onb.bio"
51
- _DE_LFT = "enp_DE.lft.bio/enp_DE.lft.bio"
52
-
53
- _TAGS = [
54
- "O",
55
- "B-PER",
56
- "I-PER",
57
- "B-ORG",
58
- "I-ORG",
59
- "B-LOC",
60
- "I-LOC",
61
- ]
62
-
63
-
64
- class EuroNewsConfig(datasets.BuilderConfig):
65
- """BuilderConfig for Europana Newspaper"""
66
-
67
- def __init__(self, **kwargs):
68
- """BuilderConfig for Europana Newspaper.
69
-
70
- Args:
71
- **kwargs: keyword arguments forwarded to super.
72
- """
73
- super(EuroNewsConfig, self).__init__(**kwargs)
74
-
75
-
76
- class Euronews(datasets.GeneratorBasedBuilder):
77
- """Europana Newspaper dataset."""
78
-
79
- BUILDER_CONFIGS = [
80
- EuroNewsConfig(
81
- name="fr-bnf", version=datasets.Version("1.0.0"), description="National Library of France Dataset"
82
- ),
83
- EuroNewsConfig(
84
- name="nl-kb", version=datasets.Version("1.0.0"), description="National Library of the Netherlands Dataset"
85
- ),
86
- EuroNewsConfig(name="de-sbb", version=datasets.Version("1.0.0"), description="Berlin State Library Dataset"),
87
- EuroNewsConfig(
88
- name="de-onb", version=datasets.Version("1.0.0"), description="Austrian National Library Dataset"
89
- ),
90
- EuroNewsConfig(
91
- name="de-lft", version=datasets.Version("1.0.0"), description="Dr Friedrich Teßmann Library Dataset"
92
- ),
93
- ]
94
-
95
- def _info(self):
96
- return datasets.DatasetInfo(
97
- description=_DESCRIPTION,
98
- features=datasets.Features(
99
- {
100
- "id": datasets.Value("string"),
101
- "tokens": datasets.Sequence(datasets.Value("string")),
102
- "ner_tags": datasets.Sequence(datasets.features.ClassLabel(names=_TAGS)),
103
- }
104
- ),
105
- supervised_keys=None,
106
- homepage="https://github.com/EuropeanaNewspapers/ner-corpora",
107
- citation=_CITATION,
108
- )
109
-
110
- def _split_generators(self, dl_manager):
111
- """Returns SplitGenerators."""
112
- if self.config.name == "fr-bnf":
113
- url_to_download = _URL + _FR_BNF
114
- elif self.config.name == "nl-kb":
115
- url_to_download = _URL + _NL_KB
116
- elif self.config.name == "de-sbb":
117
- url_to_download = _URL + _DE_SBB
118
- elif self.config.name == "de-onb":
119
- url_to_download = _URL + _DE_ONB
120
- elif self.config.name == "de-lft":
121
- url_to_download = _URL + _DE_LFT
122
-
123
- downloaded_files = dl_manager.download_and_extract(url_to_download)
124
-
125
- return [
126
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files}),
127
- ]
128
-
129
- def _generate_examples(self, filepath):
130
- logger.info("⏳ Generating examples from = %s", filepath)
131
- with open(filepath, encoding="utf-8") as f:
132
- guid = 0
133
- tokens = []
134
- ner_tags = []
135
- for line in f:
136
- splits = line.split()
137
- if len(splits) != 2:
138
- continue
139
- if line == "" or line == "\n":
140
- if tokens:
141
- yield guid, {
142
- "id": str(guid),
143
- "tokens": tokens,
144
- "ner_tags": ner_tags,
145
- }
146
- guid += 1
147
- tokens = []
148
- ner_tags = []
149
- else:
150
- # Europana Newspaper tokens are space separated
151
- tag = splits[1].rstrip().upper()
152
- if tag not in _TAGS:
153
- continue
154
- tokens.append(splits[0])
155
- ner_tags.append(tag)
156
- # last example
157
- yield guid, {
158
- "id": str(guid),
159
- "tokens": tokens,
160
- "ner_tags": ner_tags,
161
- }