IlyaGusev commited on
Commit
2b65a1d
1 Parent(s): 650e2f8
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +44 -0
  3. habr.jsonl.zst +3 -0
  4. habr.py +93 -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
+ habr.jsonl.zst filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ features:
4
+ - name: text
5
+ dtype: string
6
+ - name: meta
7
+ struct:
8
+ - name: id
9
+ dtype: uint32
10
+ - name: time_published
11
+ dtype: uint64
12
+ - name: title
13
+ dtype: string
14
+ - name: author
15
+ dtype: string
16
+ - name: statistics
17
+ struct:
18
+ - name: commentsCount
19
+ dtype: uint32
20
+ - name: favoritesCount
21
+ dtype: uint32
22
+ - name: readingCount
23
+ dtype: uint32
24
+ - name: score
25
+ dtype: int32
26
+ - name: votesCount
27
+ dtype: int32
28
+ - name: votesCountPlus
29
+ dtype: int32
30
+ - name: votesCountMinus
31
+ dtype: int32
32
+ splits:
33
+ - name: train
34
+ num_bytes: 3734746780
35
+ num_examples: 296802
36
+ download_size: 1084715944
37
+ dataset_size: 3734746780
38
+ task_categories:
39
+ - text-generation
40
+ language:
41
+ - ru
42
+ ---
43
+
44
+ # Habrahabr dataset
habr.jsonl.zst ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f0874d5d7e1e4e0932571c4bb4bb776810a50f5eb57fb630849960316b83ccc
3
+ size 1084715944
habr.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Habrahabr dataset"""
18
+
19
+ import os
20
+ import io
21
+
22
+ import zstandard
23
+ import jsonlines
24
+ import datasets
25
+
26
+ try:
27
+ import simdjson
28
+ parser = simdjson.Parser()
29
+ def parse_json(x):
30
+ try:
31
+ return parser.parse(x).as_dict()
32
+ except ValueError:
33
+ return
34
+ except ImportError:
35
+ import json
36
+ def parse_json(x):
37
+ return json.loads(x)
38
+
39
+
40
+ _DESCRIPTION = "Habrahabr dataset"
41
+ _URL = "habr.jsonl.zst"
42
+
43
+
44
+ class RuLMDataset(datasets.GeneratorBasedBuilder):
45
+ """Habrahabr dataset"""
46
+
47
+ VERSION = datasets.Version("0.0.1")
48
+
49
+ BUILDER_CONFIGS = [
50
+ datasets.BuilderConfig(name="default", version=VERSION, description=""),
51
+ ]
52
+
53
+ DEFAULT_CONFIG_NAME = "default"
54
+
55
+ def _info(self):
56
+ features = datasets.Features(
57
+ {
58
+ "text": datasets.Value("string"),
59
+ "meta": {
60
+ "id": datasets.Value("uint32"),
61
+ "time_published": datasets.Value("uint64"),
62
+ "title": datasets.Value("string"),
63
+ "author": datasets.Value("string"),
64
+ "statistics": {
65
+ "commentsCount": datasets.Value("uint32"),
66
+ "favoritesCount": datasets.Value("uint32"),
67
+ "readingCount": datasets.Value("uint32"),
68
+ "score": datasets.Value("int32"),
69
+ "votesCount": datasets.Value("int32"),
70
+ "votesCountPlus": datasets.Value("int32"),
71
+ "votesCountMinus": datasets.Value("int32")
72
+ }
73
+ }
74
+ }
75
+ )
76
+ return datasets.DatasetInfo(
77
+ description=_DESCRIPTION,
78
+ features=features
79
+ )
80
+
81
+ def _split_generators(self, dl_manager):
82
+ downloaded_file = dl_manager.download(_URL)
83
+ return [
84
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"path": downloaded_file}),
85
+ ]
86
+
87
+ def _generate_examples(self, path):
88
+ with open(path, "rb") as f:
89
+ cctx = zstandard.ZstdDecompressor()
90
+ reader_stream = io.BufferedReader(cctx.stream_reader(f))
91
+ reader = jsonlines.Reader(reader_stream, loads=parse_json)
92
+ for id_, item in enumerate(reader):
93
+ yield id_, {"text": item["text"], "meta": item["meta"]}