cathw commited on
Commit
bff96c9
·
verified ·
1 Parent(s): c5b8a78

Upload reddit_climate_comment.py

Browse files
Files changed (1) hide show
  1. reddit_climate_comment.py +1 -37
reddit_climate_comment.py CHANGED
@@ -67,43 +67,7 @@ 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
-
71
- comments = []
72
- for comment in post['Comments']:
73
- comment_id = comment['CommentID']
74
- comment_author = comment['CommentAuthor']
75
- comment_body = comment['CommentBody'] if comment['CommentBody'] != "" else None
76
- comment_timestamp = comment['CommentTimestamp']
77
- comment_upvotes = int(comment['CommentUpvotes']) if comment['CommentUpvotes'] else None
78
- comment_permalink = comment['CommentPermalink']
79
-
80
- replies = []
81
- for reply in comment.get('Replies', []):
82
- reply_id = reply['ReplyID']
83
- reply_author = reply['ReplyAuthor']
84
- reply_body = reply['ReplyBody'] if reply['ReplyBody'] != "" else None
85
- reply_timestamp = reply['ReplyTimestamp']
86
- reply_upvotes = int(reply['ReplyUpvotes']) if reply['ReplyUpvotes'] else None
87
- reply_permalink = reply['ReplyPermalink']
88
-
89
- replies.append({
90
- "ReplyID": reply_id,
91
- "ReplyAuthor": reply_author,
92
- "ReplyBody": reply_body,
93
- "ReplyTimestamp": reply_timestamp,
94
- "ReplyUpvotes": reply_upvotes,
95
- "ReplyPermalink": reply_permalink
96
- })
97
-
98
- comments.append({
99
- "CommentID": comment_id,
100
- "CommentAuthor": comment_author,
101
- "CommentBody": comment_body,
102
- "CommentTimestamp": comment_timestamp,
103
- "CommentUpvotes": comment_upvotes,
104
- "CommentPermalink": comment_permalink,
105
- "Replies": replies
106
- })
107
 
108
  yield post_id, {
109
  "id": post_id,
 
67
  post_timestamp = post['PostTimestamp']
68
  post_upvotes = int(post['PostUpvotes']) if post['PostUpvotes'] else None
69
  post_permalink = post['PostPermalink']
70
+ comments = post['Comments']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  yield post_id, {
73
  "id": post_id,