lhoestq HF Staff commited on
Commit
9f49e25
·
verified ·
1 Parent(s): dc8e3b2

Delete loading script

Browse files
Files changed (1) hide show
  1. openwebtext-10k.py +0 -89
openwebtext-10k.py DELETED
@@ -1,89 +0,0 @@
1
- # coding=utf-8
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
- """The Open WebText Corpus"""
16
-
17
-
18
- import os
19
- import re
20
- from itertools import chain
21
-
22
- import datasets
23
-
24
-
25
- _CITATION = """\
26
- @misc{Gokaslan2019OpenWeb,
27
- title={OpenWebText Corpus},
28
- author={Aaron Gokaslan*, Vanya Cohen*, Ellie Pavlick, Stefanie Tellex},
29
- howpublished{\\url{http://Skylion007.github.io/OpenWebTextCorpus}},
30
- year={2019}
31
- }
32
- """
33
-
34
- _DESCRIPTION = """\
35
- An open-source replication of the WebText dataset from OpenAI.
36
-
37
- This is a small subset representing the first 10K records from the original dataset - created for testing.
38
-
39
- The full 8M-record dataset is at https://huggingface.co/datasets/openwebtext
40
- """
41
-
42
- _URL = "https://cdn-datasets.huggingface.co/nlp/datasets/openwebtext/openwebtext-10k.tar.xz"
43
-
44
- class Openwebtext10k(datasets.GeneratorBasedBuilder):
45
- """The Open WebText dataset."""
46
-
47
- BUILDER_CONFIGS = [
48
- datasets.BuilderConfig(
49
- name="plain_text",
50
- description="Plain text",
51
- version=datasets.Version("1.0.0"),
52
- )
53
- ]
54
-
55
- def _info(self):
56
- return datasets.DatasetInfo(
57
- description=_DESCRIPTION,
58
- features=datasets.Features({"text": datasets.Value("string")}),
59
- homepage="https://skylion007.github.io/OpenWebTextCorpus/",
60
- citation=_CITATION,
61
- )
62
-
63
- def _split_generators(self, dl_manager):
64
- dl_dir = dl_manager.download_and_extract(_URL)
65
- owt_dir = os.path.join(dl_dir, "openwebtext-10k")
66
- subset_xzs = [
67
- os.path.join(owt_dir, file_name)
68
- for file_name in sorted(os.listdir(owt_dir))
69
- if file_name.endswith("xz") # filter out ...xz.lock
70
- ]
71
- ex_dirs = dl_manager.extract(subset_xzs, num_proc=round(os.cpu_count() * 0.75))
72
- nested_txt_files = [
73
- [
74
- os.path.join(ex_dir, txt_file_name)
75
- for txt_file_name in sorted(os.listdir(ex_dir))
76
- if txt_file_name.endswith("txt")
77
- ]
78
- for ex_dir in ex_dirs
79
- ]
80
- txt_files = chain(*nested_txt_files)
81
- return [
82
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"txt_files": txt_files}),
83
- ]
84
-
85
- def _generate_examples(self, txt_files):
86
- """Yields examples."""
87
- for idx, filepath in enumerate(txt_files):
88
- with open(filepath, encoding="utf-8") as f:
89
- yield idx, {"text": re.sub("\n\n\n+", "\n\n", f.read()).strip()}