shjwudp commited on
Commit
2a69d5c
1 Parent(s): e395237

feat: init topic & replies dataset

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -0
  2. README.md +119 -0
  3. v2ex.py +146 -0
  4. v2ex_replies.jsonl.gz +3 -0
  5. v2ex_topic.jsonl.gz +3 -0
.gitattributes CHANGED
@@ -51,3 +51,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
51
  *.jpg filter=lfs diff=lfs merge=lfs -text
52
  *.jpeg filter=lfs diff=lfs merge=lfs -text
53
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
51
  *.jpg filter=lfs diff=lfs merge=lfs -text
52
  *.jpeg filter=lfs diff=lfs merge=lfs -text
53
  *.webp filter=lfs diff=lfs merge=lfs -text
54
+ v2ex_replies.jsonl.gz filter=lfs diff=lfs merge=lfs -text
55
+ v2ex_topic.jsonl.gz filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,122 @@
1
  ---
2
  license: cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
1
  ---
2
  license: cc
3
+ dataset_info:
4
+ - config_name: topic
5
+ features:
6
+ - name: id
7
+ dtype: int64
8
+ - name: title
9
+ dtype: string
10
+ - name: content
11
+ dtype: string
12
+ - name: content_rendered
13
+ dtype: string
14
+ - name: syntax
15
+ dtype: int64
16
+ - name: url
17
+ dtype: string
18
+ - name: replies
19
+ dtype: int64
20
+ - name: last_reply_by
21
+ dtype: string
22
+ - name: created
23
+ dtype: int64
24
+ - name: last_modified
25
+ dtype: int64
26
+ - name: last_touched
27
+ dtype: int64
28
+ - name: member
29
+ struct:
30
+ - name: id
31
+ dtype: int64
32
+ - name: username
33
+ dtype: string
34
+ - name: bio
35
+ dtype: string
36
+ - name: website
37
+ dtype: string
38
+ - name: github
39
+ dtype: string
40
+ - name: url
41
+ dtype: string
42
+ - name: avatar
43
+ dtype: string
44
+ - name: created
45
+ dtype: int64
46
+ - name: node
47
+ struct:
48
+ - name: id
49
+ dtype: int64
50
+ - name: url
51
+ dtype: string
52
+ - name: name
53
+ dtype: string
54
+ - name: title
55
+ dtype: string
56
+ - name: header
57
+ dtype: string
58
+ - name: footer
59
+ dtype: string
60
+ - name: avatar
61
+ dtype: string
62
+ - name: topics
63
+ dtype: int64
64
+ - name: created
65
+ dtype: int64
66
+ - name: last_modified
67
+ dtype: int64
68
+ - name: supplements
69
+ sequence:
70
+ - name: id
71
+ dtype: int64
72
+ - name: content
73
+ dtype: string
74
+ - name: content_rendered
75
+ dtype: string
76
+ - name: syntax
77
+ dtype: int64
78
+ - name: created
79
+ dtype: int64
80
+ splits:
81
+ - name: train
82
+ num_bytes: 522790208
83
+ num_examples: 262120
84
+ download_size: 153558181
85
+ dataset_size: 522790208
86
+ - config_name: replies
87
+ features:
88
+ - name: id
89
+ dtype: int64
90
+ - name: content
91
+ dtype: string
92
+ - name: content_rendered
93
+ dtype: string
94
+ - name: created
95
+ dtype: int64
96
+ - name: member
97
+ struct:
98
+ - name: id
99
+ dtype: int64
100
+ - name: username
101
+ dtype: string
102
+ - name: bio
103
+ dtype: string
104
+ - name: website
105
+ dtype: string
106
+ - name: github
107
+ dtype: string
108
+ - name: url
109
+ dtype: string
110
+ - name: avatar
111
+ dtype: string
112
+ - name: created
113
+ dtype: int64
114
+ - name: topic_id
115
+ dtype: int64
116
+ splits:
117
+ - name: train
118
+ num_bytes: 1554954801
119
+ num_examples: 3553953
120
+ download_size: 462827899
121
+ dataset_size: 1554954801
122
  ---
v2ex.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gzip
3
+
4
+ import datasets
5
+ from datasets import Value, Sequence
6
+
7
+
8
+ logger = datasets.logging.get_logger(__name__)
9
+
10
+
11
+ _DESCRIPTION = """\
12
+ V2EX is a dataset curated by https://www.v2ex.com/ open data.
13
+ """
14
+
15
+ _HOMEPAGE = "https://huggingface.co/datasets/Dialogue-Model-Research-Group/v2ex"
16
+
17
+ _DATA_URLS = {
18
+ "topic": "v2ex_topic.jsonl.gz",
19
+ "replies": "v2ex_replies.jsonl.gz",
20
+ }
21
+
22
+
23
+ class V2EXConfig(datasets.BuilderConfig):
24
+ """BuilderConfig for shu."""
25
+
26
+ def __init__(self, *args, subsets, **kwargs) -> None:
27
+ """BuilderConfig for shu.
28
+ Args:
29
+ **kwargs: keyword arguments forwarded to super.
30
+ """
31
+ super(V2EXConfig, self).__init__(
32
+ *args,
33
+ name="+".join(subsets),
34
+ **kwargs
35
+ )
36
+ self.subsets = subsets
37
+
38
+
39
+ class V2EX(datasets.GeneratorBasedBuilder):
40
+ """V2EX: Chinese book dataset."""
41
+
42
+ VERSION = datasets.Version("0.1.0")
43
+
44
+ BUILDER_CONFIG_CLASS = V2EXConfig
45
+ BUILDER_CONFIGS = [V2EXConfig(subsets=[subset]) for subset in _DATA_URLS]
46
+ DEFAULT_CONFIG_NAME = "topic"
47
+
48
+ def _info(self):
49
+ if self.config.name == "topic":
50
+ features = datasets.Features({
51
+ "id": Value("int64"),
52
+ "title": Value("string"),
53
+ "content": Value("string"),
54
+ "content_rendered": Value("string"),
55
+ "syntax": Value("int64"),
56
+ "url": Value("string"),
57
+ "replies": Value("int64"),
58
+ "last_reply_by": Value("string"),
59
+ "created": Value("int64"),
60
+ "last_modified": Value("int64"),
61
+ "last_touched": Value("int64"),
62
+ "member": {
63
+ "id": Value("int64"),
64
+ "username": Value("string"),
65
+ "bio": Value("string"),
66
+ "website": Value("string"),
67
+ "github": Value("string"),
68
+ "url": Value("string"),
69
+ "avatar": Value("string"),
70
+ "created": Value("int64"),
71
+ },
72
+ "node": {
73
+ "id": Value("int64"),
74
+ "url": Value("string"),
75
+ "name": Value("string"),
76
+ "title": Value("string"),
77
+ "header": Value("string"),
78
+ "footer": Value("string"),
79
+ "avatar": Value("string"),
80
+ "topics": Value("int64"),
81
+ "created": Value("int64"),
82
+ "last_modified": Value("int64"),
83
+ },
84
+ "supplements": Sequence({
85
+ "id": Value("int64"),
86
+ "content": Value("string"),
87
+ "content_rendered": Value("string"),
88
+ "syntax": Value("int64"),
89
+ "created": Value("int64"),
90
+ }),
91
+ })
92
+ elif self.config.name == "replies":
93
+ features = datasets.Features({
94
+ "id": Value(dtype="int64", id=None),
95
+ "content": Value(dtype="string", id=None),
96
+ "content_rendered": Value(dtype="string", id=None),
97
+ "created": Value(dtype="int64", id=None),
98
+ "member": {
99
+ "id": Value(dtype="int64", id=None),
100
+ "username": Value(dtype="string", id=None),
101
+ "bio": Value(dtype="string", id=None),
102
+ "website": Value(dtype="string", id=None),
103
+ "github": Value(dtype="string", id=None),
104
+ "url": Value(dtype="string", id=None),
105
+ "avatar": Value(dtype="string", id=None),
106
+ "created": Value(dtype="int64", id=None)
107
+ },
108
+ "topic_id": Value(dtype="int64", id=None),
109
+ })
110
+ else:
111
+ raise NotImplementedError(
112
+ "This task is not implemented. If you believe"
113
+ " this task was recently added to the CLUE benchmark, "
114
+ "please open a GitHub issue and we will add it."
115
+ )
116
+
117
+ return datasets.DatasetInfo(
118
+ description=_DESCRIPTION,
119
+ features=features,
120
+ homepage=_HOMEPAGE,
121
+ )
122
+
123
+ def _split_generators(self, dl_manager):
124
+ data_urls = {subset: _DATA_URLS[subset] for subset in self.config.subsets}
125
+ archive = dl_manager.download(data_urls)
126
+
127
+ return [
128
+ datasets.SplitGenerator(
129
+ name=datasets.Split.TRAIN,
130
+ gen_kwargs={
131
+ "files": {
132
+ subset: archive[subset] for subset in self.config.subsets
133
+ },
134
+ },
135
+ ),
136
+ ]
137
+
138
+ def _generate_examples(self, files):
139
+ key = 0
140
+ for subset in files:
141
+ filepath = files[subset]
142
+ for line in gzip.open(filepath, "rt", encoding="utf-8"):
143
+ j = json.loads(line)
144
+ yield key, j
145
+ key += 1
146
+
v2ex_replies.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b09a83bd84b90d08bfc3fb34b484e86c7a065de3bdfdd5cb782777be0ef820f2
3
+ size 462827899
v2ex_topic.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5317b0cbec00baa2d9b4a7d87c7d58b1f2eba6a22a5bdd6960d648e1779f5487
3
+ size 153558181