saattrupdan commited on
Commit
50e2efd
1 Parent(s): 4191867

chore: Rename script

Browse files
Files changed (2) hide show
  1. scandi-wiki.py +118 -0
  2. scandi_wiki.py +0 -118
scandi-wiki.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 The HuggingFace Datasets Authors and Dan Saattrup Nielsen.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Python build script for the ScandiWiki dataset."""
15
+
16
+
17
+ import json
18
+ from pathlib import Path
19
+ from typing import List
20
+
21
+ from datasets import Version
22
+ from datasets.builder import BuilderConfig, GeneratorBasedBuilder
23
+ from datasets.download import DownloadManager
24
+ from datasets.features import Features, Value
25
+ from datasets.info import DatasetInfo
26
+ from datasets.splits import SplitGenerator
27
+
28
+ _DESCRIPTION = """
29
+ ScandiWiki is a parsed and deduplicated version of the Danish, Norwegian Bokmål,
30
+ Norwegian Nynorsk, Swedish, Icelandic and Faroese Wikipedia corpora, as of January
31
+ 2023.
32
+ """
33
+
34
+ _LICENSE = "CC BY-SA 4.0"
35
+ _BASE_URL = (
36
+ "https://huggingface.co/datasets/alexandrainst/scandi-wiki/resolve/main/data/"
37
+ )
38
+
39
+ # _CITATION = """
40
+ # @InProceedings{huggingface:dataset,
41
+ # title = {ScandiWiki: A Scandinavian Wikipedia Dump},
42
+ # author={Dan Saattrup Nielsen},
43
+ # year={2022}
44
+ # }
45
+ # """
46
+
47
+
48
+ class ScandiWiki(GeneratorBasedBuilder):
49
+ """Scandinavian part of Wikipedia."""
50
+
51
+ VERSION = Version("1.0.1")
52
+
53
+ BUILDER_CONFIGS = [
54
+ BuilderConfig(
55
+ name="da",
56
+ version=VERSION,
57
+ description="The deduplicated Danish part of Wikipedia.",
58
+ ),
59
+ BuilderConfig(
60
+ name="sv",
61
+ version=VERSION,
62
+ description="The deduplicated Swedish part of Wikipedia.",
63
+ ),
64
+ BuilderConfig(
65
+ name="nb",
66
+ version=VERSION,
67
+ description="The deduplicated Norwegian Bokmål part of Wikipedia.",
68
+ ),
69
+ BuilderConfig(
70
+ name="nn",
71
+ version=VERSION,
72
+ description="The deduplicated Norwegian Nynorsk part of Wikipedia.",
73
+ ),
74
+ BuilderConfig(
75
+ name="is",
76
+ version=VERSION,
77
+ description="The deduplicated Icelandic part of Wikipedia.",
78
+ ),
79
+ BuilderConfig(
80
+ name="fo",
81
+ version=VERSION,
82
+ description="The deduplicated Faroese part of Wikipedia.",
83
+ ),
84
+ ]
85
+
86
+ def _info(self) -> DatasetInfo:
87
+ features = Features(
88
+ {
89
+ "id": Value("string"),
90
+ "url": Value("string"),
91
+ "title": Value("string"),
92
+ "text": Value("string"),
93
+ }
94
+ )
95
+ return DatasetInfo(
96
+ description=_DESCRIPTION,
97
+ features=features,
98
+ license=_LICENSE,
99
+ # homepage=_HOMEPAGE,
100
+ # citation=_CITATION,
101
+ )
102
+
103
+ def _split_generators(self, dl_manager: DownloadManager) -> List[SplitGenerator]:
104
+ url = f"{_BASE_URL}/{self.config.name}.jsonl"
105
+ downloaded_file = dl_manager.download_and_extract(url)
106
+ return [
107
+ SplitGenerator(
108
+ name="train",
109
+ gen_kwargs=dict(filepath=downloaded_file),
110
+ ),
111
+ ]
112
+
113
+ def _generate_examples(self, filepath: str):
114
+ if self.config.name == "da":
115
+ with Path(filepath).open(encoding="utf-8") as f:
116
+ for key, row in enumerate(f):
117
+ data = json.loads(row)
118
+ yield key, data
scandi_wiki.py DELETED
@@ -1,118 +0,0 @@
1
- # Copyright 2022 The HuggingFace Datasets Authors and Dan Saattrup Nielsen.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- """Python build script for the ScandiWiki dataset."""
15
-
16
-
17
- # import json
18
- # from pathlib import Path
19
- # from typing import List
20
- #
21
- # from datasets import Version
22
- # from datasets.builder import BuilderConfig, GeneratorBasedBuilder
23
- # from datasets.download import DownloadManager
24
- # from datasets.features import Features, Value
25
- # from datasets.info import DatasetInfo
26
- # from datasets.splits import SplitGenerator
27
- #
28
- # _DESCRIPTION = """
29
- # ScandiWiki is a parsed and deduplicated version of the Danish, Norwegian Bokmål,
30
- # Norwegian Nynorsk, Swedish, Icelandic and Faroese Wikipedia corpora, as of January
31
- # 2023.
32
- # """
33
- #
34
- # _LICENSE = "CC BY-SA 4.0"
35
- # _BASE_URL = (
36
- # "https://huggingface.co/datasets/alexandrainst/scandi-wiki/resolve/main/data/"
37
- # )
38
- #
39
- # # _CITATION = """
40
- # # @InProceedings{huggingface:dataset,
41
- # # title = {ScandiWiki: A Scandinavian Wikipedia Dump},
42
- # # author={Dan Saattrup Nielsen},
43
- # # year={2022}
44
- # # }
45
- # # """
46
- #
47
- #
48
- # class ScandiWiki(GeneratorBasedBuilder):
49
- # """Scandinavian part of Wikipedia."""
50
- #
51
- # VERSION = Version("1.0.1")
52
- #
53
- # BUILDER_CONFIGS = [
54
- # BuilderConfig(
55
- # name="da",
56
- # version=VERSION,
57
- # description="The deduplicated Danish part of Wikipedia.",
58
- # ),
59
- # BuilderConfig(
60
- # name="sv",
61
- # version=VERSION,
62
- # description="The deduplicated Swedish part of Wikipedia.",
63
- # ),
64
- # BuilderConfig(
65
- # name="nb",
66
- # version=VERSION,
67
- # description="The deduplicated Norwegian Bokmål part of Wikipedia.",
68
- # ),
69
- # BuilderConfig(
70
- # name="nn",
71
- # version=VERSION,
72
- # description="The deduplicated Norwegian Nynorsk part of Wikipedia.",
73
- # ),
74
- # BuilderConfig(
75
- # name="is",
76
- # version=VERSION,
77
- # description="The deduplicated Icelandic part of Wikipedia.",
78
- # ),
79
- # BuilderConfig(
80
- # name="fo",
81
- # version=VERSION,
82
- # description="The deduplicated Faroese part of Wikipedia.",
83
- # ),
84
- # ]
85
- #
86
- # def _info(self) -> DatasetInfo:
87
- # features = Features(
88
- # {
89
- # "id": Value("string"),
90
- # "url": Value("string"),
91
- # "title": Value("string"),
92
- # "text": Value("string"),
93
- # }
94
- # )
95
- # return DatasetInfo(
96
- # description=_DESCRIPTION,
97
- # features=features,
98
- # license=_LICENSE,
99
- # # homepage=_HOMEPAGE,
100
- # # citation=_CITATION,
101
- # )
102
- #
103
- # def _split_generators(self, dl_manager: DownloadManager) -> List[SplitGenerator]:
104
- # url = f"{_BASE_URL}/{self.config.name}.jsonl"
105
- # downloaded_file = dl_manager.download_and_extract(url)
106
- # return [
107
- # SplitGenerator(
108
- # name="train",
109
- # gen_kwargs=dict(filepath=downloaded_file),
110
- # ),
111
- # ]
112
- #
113
- # def _generate_examples(self, filepath: str):
114
- # if self.config.name == "da":
115
- # with Path(filepath).open(encoding="utf-8") as f:
116
- # for key, row in enumerate(f):
117
- # data = json.loads(row)
118
- # yield key, data