IlyaGusev commited on
Commit
01bc81b
1 Parent(s): 43758fa

Initial commit

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +22 -0
  3. stihi_ru.jsonl.zst +3 -0
  4. stihi_ru.py +80 -0
.gitattributes CHANGED
@@ -52,3 +52,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ stihi_ru.jsonl.zst filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ features:
4
+ - name: id
5
+ dtype: string
6
+ - name: text
7
+ dtype: string
8
+ - name: title
9
+ dtype: string
10
+ - name: genre
11
+ dtype: string
12
+ - name: topic
13
+ dtype: string
14
+ - name: author
15
+ dtype: string
16
+ splits:
17
+ - name: train
18
+ num_bytes: 6029108612
19
+ num_examples: 5151050
20
+ download_size: 1892727043
21
+ dataset_size: 6029108612
22
+ ---
stihi_ru.jsonl.zst ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:422d9ad640ac06138c3a2d5ca377bfa6e1a561ec57affe8435dc8a5028da3bc5
3
+ size 1892727043
stihi_ru.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 The HuggingFace Datasets Authors and Ilya Gusev
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
+
18
+ import os
19
+ import io
20
+
21
+ import zstandard
22
+ import jsonlines
23
+ import datasets
24
+
25
+ try:
26
+ import simdjson
27
+ parser = simdjson.Parser()
28
+ def parse_json(x):
29
+ try:
30
+ return parser.parse(x).as_dict()
31
+ except ValueError:
32
+ return
33
+ except ImportError:
34
+ import json
35
+ def parse_json(x):
36
+ return json.loads(x)
37
+
38
+
39
+ _DESCRIPTION = "Taiga stihi.ru dataset"
40
+ _URL = "stihi_ru.jsonl.zst"
41
+
42
+
43
+ class StihiRuDataset(datasets.GeneratorBasedBuilder):
44
+ VERSION = datasets.Version("0.0.1")
45
+
46
+ BUILDER_CONFIGS = [
47
+ datasets.BuilderConfig(name="default", version=VERSION, description=""),
48
+ ]
49
+
50
+ DEFAULT_CONFIG_NAME = "default"
51
+
52
+ def _info(self):
53
+ features = datasets.Features(
54
+ {
55
+ "id": datasets.Value("string"),
56
+ "text": datasets.Value("string"),
57
+ "title": datasets.Value("string"),
58
+ "genre": datasets.Value("string"),
59
+ "topic": datasets.Value("string"),
60
+ "author": datasets.Value("string"),
61
+ }
62
+ )
63
+ return datasets.DatasetInfo(
64
+ description=_DESCRIPTION,
65
+ features=features
66
+ )
67
+
68
+ def _split_generators(self, dl_manager):
69
+ downloaded_file = dl_manager.download(_URL)
70
+ return [
71
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"path": downloaded_file}),
72
+ ]
73
+
74
+ def _generate_examples(self, path):
75
+ with open(path, "rb") as f:
76
+ cctx = zstandard.ZstdDecompressor()
77
+ reader_stream = io.BufferedReader(cctx.stream_reader(f))
78
+ reader = jsonlines.Reader(reader_stream, loads=parse_json)
79
+ for id_, item in enumerate(reader):
80
+ yield id_, item