cathw commited on
Commit
63c8e77
·
verified ·
1 Parent(s): 5aa5df7

Upload reddit_climate_comment.py

Browse files
Files changed (1) hide show
  1. reddit_climate_comment.py +14 -12
reddit_climate_comment.py CHANGED
@@ -67,8 +67,8 @@ class NewDataset(GeneratorBasedBuilder):
67
  post_timestamp = post['PostTimestamp']
68
  post_upvotes = int(post['PostUpvotes']) if post['PostUpvotes'] else None
69
  post_permalink = post['PostPermalink']
70
- comments = []
71
-
72
  for i in range(len(post['Comments'])):
73
  comment_id = post['Comments'][i]['CommentID']
74
  comment_author = post['Comments'][i]['CommentAuthor']
@@ -77,15 +77,6 @@ class NewDataset(GeneratorBasedBuilder):
77
  comment_upvotes = int(post['Comments'][i]['CommentUpvotes']) if post['Comments'][i]['CommentUpvotes'] else None
78
  comment_permalink = post['Comments'][i]['CommentPermalink']
79
  replies = []
80
- comments.append({
81
- "CommentID": comment_id,
82
- "CommentAuthor": comment_author,
83
- "CommentBody": comment_body,
84
- "CommentTimestamp": comment_timestamp,
85
- "CommentUpvotes": comment_upvotes,
86
- "CommentPermalink": comment_permalink,
87
- "Replies": replies
88
- })
89
  for reply in post['Comments'][i].get('Replies', []):
90
  reply_id = reply['ReplyID']
91
  reply_author = reply['ReplyAuthor']
@@ -101,6 +92,16 @@ class NewDataset(GeneratorBasedBuilder):
101
  "ReplyUpvotes": reply_upvotes,
102
  "ReplyPermalink": reply_permalink
103
  })
 
 
 
 
 
 
 
 
 
 
104
 
105
  yield post_id, {
106
  "id": post_id,
@@ -113,5 +114,6 @@ class NewDataset(GeneratorBasedBuilder):
113
  "post_timestamp": post_timestamp,
114
  "post_upvotes": post_upvotes,
115
  "post_permalink": post_permalink,
116
- "comments": comments
117
  }
 
 
67
  post_timestamp = post['PostTimestamp']
68
  post_upvotes = int(post['PostUpvotes']) if post['PostUpvotes'] else None
69
  post_permalink = post['PostPermalink']
70
+
71
+ examples = []
72
  for i in range(len(post['Comments'])):
73
  comment_id = post['Comments'][i]['CommentID']
74
  comment_author = post['Comments'][i]['CommentAuthor']
 
77
  comment_upvotes = int(post['Comments'][i]['CommentUpvotes']) if post['Comments'][i]['CommentUpvotes'] else None
78
  comment_permalink = post['Comments'][i]['CommentPermalink']
79
  replies = []
 
 
 
 
 
 
 
 
 
80
  for reply in post['Comments'][i].get('Replies', []):
81
  reply_id = reply['ReplyID']
82
  reply_author = reply['ReplyAuthor']
 
92
  "ReplyUpvotes": reply_upvotes,
93
  "ReplyPermalink": reply_permalink
94
  })
95
+ comment_dict = {
96
+ "CommentID": comment_id,
97
+ "CommentAuthor": comment_author,
98
+ "CommentBody": comment_body,
99
+ "CommentTimestamp": comment_timestamp,
100
+ "CommentUpvotes": comment_upvotes,
101
+ "CommentPermalink": comment_permalink,
102
+ "Replies": replies
103
+ }
104
+ examples.append(comment_dict)
105
 
106
  yield post_id, {
107
  "id": post_id,
 
114
  "post_timestamp": post_timestamp,
115
  "post_upvotes": post_upvotes,
116
  "post_permalink": post_permalink,
117
+ "comments": examples
118
  }
119
+