shjwudp commited on
Commit
c36d17c
1 Parent(s): 798cbc4

feat: Initialized dataset information and collected 4363 ancient books from https://github.com/wenyuange

Browse files
Files changed (2) hide show
  1. books.jsonl.gz +3 -0
  2. shu.py +63 -0
books.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4855e99ff5d1e0d037d7eefbc3426c1a3c4b1ce286fb56ef3d55366b590c205d
3
+ size 834146732
shu.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gzip
3
+
4
+ import datasets
5
+
6
+
7
+ logger = datasets.logging.get_logger(__name__)
8
+
9
+
10
+ _DESCRIPTION = """\
11
+ shu is a chinese book dataset.
12
+ """
13
+
14
+ class ShuConfig(datasets.BuilderConfig):
15
+ """BuilderConfig for shu."""
16
+
17
+ def __init__(self, **kwargs) -> None:
18
+ """BuilderConfig for shu.
19
+ Args:
20
+ **kwargs: keyword arguments forwarded to super.
21
+ """
22
+ super(ShuConfig, self).__init__(**kwargs)
23
+
24
+
25
+ class Shu(datasets.GeneratorBasedBuilder):
26
+ """shu: Chinese book dataset."""
27
+
28
+ BUILDER_CONFIGS = [
29
+ ShuConfig(
30
+ name="plain_text",
31
+ version=datasets.Version("0.1.0", ""),
32
+ description="Plain text",
33
+ )
34
+ ]
35
+
36
+ def _info(self):
37
+ return datasets.DatasetInfo(
38
+ description=_DESCRIPTION,
39
+ features=datasets.Features({
40
+ "name": datasets.Value("string"),
41
+ "text": datasets.Value("string"),
42
+ }),
43
+ homepage="https://github.com/shjwudp/shu",
44
+ )
45
+
46
+ def _split_generators(self, dl_manager):
47
+ return [
48
+ datasets.SplitGenerator(
49
+ name=datasets.Split.TRAIN,
50
+ gen_kwargs={
51
+ "filepath": "./books.jsonl.gz",
52
+ }
53
+ ),
54
+ ]
55
+
56
+ def _generate_examples(self, filepath):
57
+ logger.info(f"generating examples from = {filepath}")
58
+ key = 0
59
+ print("filepath", filepath)
60
+ for line in gzip.open(filepath, "rt", encoding="utf-8"):
61
+ j = json.loads(line)
62
+ yield key, j
63
+ key += 1