initial commit
Browse files- .gitignore +1 -0
- kowikitext-20221001.parquet +3 -0
- kowikitext_dataset_script.py +146 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
raw/
|
kowikitext-20221001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:044a898dd91beea189fe067c7aab4d3ed2c54fec8b2ff12d923918bc4a52c834
|
3 |
+
size 502246083
|
kowikitext_dataset_script.py
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://github.com/huggingface/datasets/blob/main/templates/new_dataset_script.py
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
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 |
+
# TODO: Address all TODOs and remove all explanatory comments
|
16 |
+
"""TODO: Add a description here."""
|
17 |
+
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import json
|
21 |
+
import os
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
|
26 |
+
# TODO: Add BibTeX citation
|
27 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
28 |
+
_CITATION = """\
|
29 |
+
@InProceedings{huggingface:dataset,
|
30 |
+
title = {kowikitext},
|
31 |
+
author={Wikipedia},
|
32 |
+
year={2022}
|
33 |
+
}
|
34 |
+
"""
|
35 |
+
|
36 |
+
# TODO: Add description of the dataset here
|
37 |
+
# You can copy an official description
|
38 |
+
_DESCRIPTION = """\
|
39 |
+
한국어 위키피디아 article
|
40 |
+
"""
|
41 |
+
|
42 |
+
# TODO: Add a link to an official homepage for the dataset here
|
43 |
+
_HOMEPAGE = "https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:%EB%8C%80%EB%AC%B8"
|
44 |
+
|
45 |
+
# TODO: Add the licence for the dataset here if you can find it
|
46 |
+
_LICENSE = "https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
|
47 |
+
|
48 |
+
# TODO: Add link to the official dataset URLs here
|
49 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
50 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
51 |
+
_URLS = {
|
52 |
+
"20221001": "https://huggingface.co/datasets/heegyu/kowikitext/raw/main/kowikitext-20221001.parquet",
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
57 |
+
class KowikitextDataset(datasets.GeneratorBasedBuilder):
|
58 |
+
"""한국어 위키 article 덤프 데이터셋"""
|
59 |
+
|
60 |
+
VERSION = datasets.Version("1.1.0")
|
61 |
+
|
62 |
+
# This is an example of a dataset with multiple configurations.
|
63 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
64 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
65 |
+
|
66 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
67 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
68 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
69 |
+
|
70 |
+
# You will be able to load one or the other configurations in the following list with
|
71 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
72 |
+
BUILDER_CONFIGS = [
|
73 |
+
datasets.BuilderConfig(name="20221001", version=VERSION, description="2022/10/01 한국어 위키피디아 article 덤프"),
|
74 |
+
]
|
75 |
+
|
76 |
+
DEFAULT_CONFIG_NAME = "20221001" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
77 |
+
|
78 |
+
def _info(self):
|
79 |
+
features = datasets.Features(
|
80 |
+
{
|
81 |
+
"id": datasets.Value("string"),
|
82 |
+
"revid": datasets.Value("string"),
|
83 |
+
"url": datasets.Value("string"),
|
84 |
+
"title": datasets.Value("string"),
|
85 |
+
"text": datasets.Value("string")
|
86 |
+
}
|
87 |
+
)
|
88 |
+
return datasets.DatasetInfo(
|
89 |
+
# This is the description that will appear on the datasets page.
|
90 |
+
description=_DESCRIPTION,
|
91 |
+
# This defines the different columns of the dataset and their types
|
92 |
+
features=features, # Here we define them above because they are different between the two configurations
|
93 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
94 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
95 |
+
# supervised_keys=("sentence", "label"),
|
96 |
+
# Homepage of the dataset for documentation
|
97 |
+
homepage=_HOMEPAGE,
|
98 |
+
# License for the dataset if available
|
99 |
+
license=_LICENSE,
|
100 |
+
# Citation for the dataset
|
101 |
+
citation=_CITATION,
|
102 |
+
)
|
103 |
+
|
104 |
+
def _split_generators(self, dl_manager):
|
105 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
106 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
107 |
+
|
108 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
109 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
110 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
111 |
+
urls = _URLS[self.config.name]
|
112 |
+
data_dir = dl_manager.download_and_extract(urls)
|
113 |
+
return [
|
114 |
+
datasets.SplitGenerator(
|
115 |
+
name=datasets.Split.TRAIN,
|
116 |
+
# These kwargs will be passed to _generate_examples
|
117 |
+
gen_kwargs={
|
118 |
+
"filepath": os.path.join(data_dir, "train.jsonl"),
|
119 |
+
"split": "train",
|
120 |
+
},
|
121 |
+
),
|
122 |
+
# datasets.SplitGenerator(
|
123 |
+
# name=datasets.Split.VALIDATION,
|
124 |
+
# # These kwargs will be passed to _generate_examples
|
125 |
+
# gen_kwargs={
|
126 |
+
# "filepath": os.path.join(data_dir, "dev.jsonl"),
|
127 |
+
# "split": "dev",
|
128 |
+
# },
|
129 |
+
# ),
|
130 |
+
# datasets.SplitGenerator(
|
131 |
+
# name=datasets.Split.TEST,
|
132 |
+
# # These kwargs will be passed to _generate_examples
|
133 |
+
# gen_kwargs={
|
134 |
+
# "filepath": os.path.join(data_dir, "test.jsonl"),
|
135 |
+
# "split": "test"
|
136 |
+
# },
|
137 |
+
# ),
|
138 |
+
]
|
139 |
+
|
140 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
141 |
+
def _generate_examples(self, filepath, split):
|
142 |
+
with open(filepath, encoding="utf-8") as f:
|
143 |
+
for key, row in enumerate(f):
|
144 |
+
data = json.loads(row)
|
145 |
+
# Yields examples as (key, example) tuples
|
146 |
+
yield key, data
|