shjwudp commited on
Commit
81ba15f
·
1 Parent(s): 1cd2202

feat: add books with full volume of original text books; add clean, simplified chinese version, and filtered out bad lines datasets

Browse files
bad_lines.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ad12a043e47f615243291b666bf20c8425085902b42474160b9eb7512922e07
3
+ size 1409160631
books.jsonl.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4855e99ff5d1e0d037d7eefbc3426c1a3c4b1ce286fb56ef3d55366b590c205d
3
- size 834146732
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20ee447bde5d72ee8b40f7205ab100b6f2fd4ecf6ed6a5f40acc65f2901f30c4
3
+ size 2300825625
books_in_simplified_chinese.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1e2e418592f05341625494d5b9ac2c8c96d283f306d1a766b1a77869358110d
3
+ size 883810382
clean_books.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d90fc8b8be2707620bae754bda193cb00ab3096738ddc4810e3e01dd025679b9
3
+ size 883820675
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"clean": {"description": "shu is a chinese book dataset.\n", "citation": "", "homepage": "https://github.com/shjwudp/shu", "license": "", "features": {"name": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "shu", "config_name": "clean", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2058524432, "num_examples": 11710, "dataset_name": "shu"}}, "download_checksums": {"clean_books.jsonl.gz": {"num_bytes": 883820675, "checksum": "d90fc8b8be2707620bae754bda193cb00ab3096738ddc4810e3e01dd025679b9"}}, "download_size": 883820675, "post_processing_size": null, "dataset_size": 2058524432, "size_in_bytes": 2942345107}, "simplified clean": {"description": "shu is a chinese book dataset.\n", "citation": "", "homepage": "https://github.com/shjwudp/shu", "license": "", "features": {"name": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "shu", "config_name": "simplified clean", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2058621856, "num_examples": 11710, "dataset_name": "shu"}}, "download_checksums": {"books_in_simplified_chinese.jsonl.gz": {"num_bytes": 883810382, "checksum": "e1e2e418592f05341625494d5b9ac2c8c96d283f306d1a766b1a77869358110d"}}, "download_size": 883810382, "post_processing_size": null, "dataset_size": 2058621856, "size_in_bytes": 2942432238}, "original text": {"description": "shu is a chinese book dataset.\n", "citation": "", "homepage": "https://github.com/shjwudp/shu", "license": "", "features": {"name": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "shu", "config_name": "original text", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5141361142, "num_examples": 15694, "dataset_name": "shu"}}, "download_checksums": {"books.jsonl.gz": {"num_bytes": 2300825625, "checksum": "20ee447bde5d72ee8b40f7205ab100b6f2fd4ecf6ed6a5f40acc65f2901f30c4"}}, "download_size": 2300825625, "post_processing_size": null, "dataset_size": 5141361142, "size_in_bytes": 7442186767}, "bad lines": {"description": "shu is a chinese book dataset.\n", "citation": "", "homepage": "https://github.com/shjwudp/shu", "license": "", "features": {"name": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "shu", "config_name": "bad lines", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2970314577, "num_examples": 15690, "dataset_name": "shu"}}, "download_checksums": {"bad_lines.jsonl.gz": {"num_bytes": 1409160631, "checksum": "9ad12a043e47f615243291b666bf20c8425085902b42474160b9eb7512922e07"}}, "download_size": 1409160631, "post_processing_size": null, "dataset_size": 2970314577, "size_in_bytes": 4379475208}}
shu.py CHANGED
@@ -11,27 +11,40 @@ _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(
@@ -40,21 +53,29 @@ class Shu(datasets.GeneratorBasedBuilder):
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
- train_text = dl_manager.download("books.jsonl.gz")
 
48
 
49
  return [
50
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_text}),
 
 
 
 
 
 
 
51
  ]
52
 
53
- def _generate_examples(self, filepath):
54
- logger.info(f"generating examples from = {filepath}")
55
  key = 0
56
- print("filepath", filepath)
57
- for line in gzip.open(filepath, "rt", encoding="utf-8"):
58
- j = json.loads(line)
59
- yield key, j
60
- key += 1
 
 
11
  shu is a chinese book dataset.
12
  """
13
 
14
+ _HOMEPAGE = "https://github.com/shjwudp/shu"
15
+
16
+ _DATA_URLS = {
17
+ "clean": "clean_books.jsonl.gz",
18
+ "simplified clean": "books_in_simplified_chinese.jsonl.gz",
19
+ "original text": "books.jsonl.gz",
20
+ "bad lines": "bad_lines.jsonl.gz",
21
+ }
22
+
23
+
24
  class ShuConfig(datasets.BuilderConfig):
25
  """BuilderConfig for shu."""
26
 
27
+ def __init__(self, *args, subsets, **kwargs) -> None:
28
  """BuilderConfig for shu.
29
  Args:
30
  **kwargs: keyword arguments forwarded to super.
31
  """
32
+ super(ShuConfig, self).__init__(
33
+ *args,
34
+ name="+".join(subsets),
35
+ **kwargs
36
+ )
37
+ self.subsets = subsets
38
 
39
 
40
  class Shu(datasets.GeneratorBasedBuilder):
41
  """shu: Chinese book dataset."""
42
 
43
+ VERSION = datasets.Version("0.1.0")
44
+
45
+ BUILDER_CONFIG_CLASS = ShuConfig
46
+ BUILDER_CONFIGS = [ShuConfig(subsets=[subset]) for subset in _DATA_URLS]
47
+ DEFAULT_CONFIG_NAME = "simplified clean"
 
 
48
 
49
  def _info(self):
50
  return datasets.DatasetInfo(
 
53
  "name": datasets.Value("string"),
54
  "text": datasets.Value("string"),
55
  }),
56
+ homepage=_HOMEPAGE,
57
  )
58
 
59
  def _split_generators(self, dl_manager):
60
+ data_urls = {subset: _DATA_URLS[subset] for subset in self.config.subsets}
61
+ archive = dl_manager.download(data_urls)
62
 
63
  return [
64
+ datasets.SplitGenerator(
65
+ name=datasets.Split.TRAIN,
66
+ gen_kwargs={
67
+ "files": {
68
+ subset: data_urls[subset] for subset in self.config.subsets
69
+ },
70
+ },
71
+ ),
72
  ]
73
 
74
+ def _generate_examples(self, files):
 
75
  key = 0
76
+ for subset in files:
77
+ filepath = files[subset]
78
+ for line in gzip.open(filepath, "rt", encoding="utf-8"):
79
+ j = json.loads(line)
80
+ yield key, j
81
+ key += 1