cathw commited on
Commit
3de1fa9
·
verified ·
1 Parent(s): 6bfb168

Upload reddit_climate_comment.py

Browse files
Files changed (1) hide show
  1. reddit_climate_comment.py +1 -39
reddit_climate_comment.py CHANGED
@@ -67,45 +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
- comments = []
71
-
72
- if 'comments' in post:
73
- comment_ids = post['comments'].get('CommentID', [])
74
- comment_authors = post['comments'].get('CommentAuthor', [])
75
- comment_bodies = post['comments'].get('CommentBody', [])
76
- comment_timestamps = post['comments'].get('CommentTimestamp', [])
77
- comment_upvotes = post['comments'].get('CommentUpvotes', [])
78
- comment_permalinks = post['comments'].get('CommentPermalink', [])
79
- reply_lists = post['comments'].get('Replies', [])
80
-
81
- for i, comment_id in enumerate(comment_ids):
82
- comment_author = comment_authors[i]
83
- comment_body = comment_bodies[i] if i < len(comment_bodies) else None
84
- comment_timestamp = comment_timestamps[i] if i < len(comment_timestamps) else None
85
- comment_upvote = comment_upvotes[i] if i < len(comment_upvotes) else None
86
- comment_permalink = comment_permalinks[i] if i < len(comment_permalinks) else None
87
- replies = []
88
-
89
- reply_list = reply_lists[i] if i < len(reply_lists) else []
90
- for reply in reply_list:
91
- replies.append({
92
- "ReplyID": reply.get("ReplyID", ""),
93
- "ReplyAuthor": reply.get("ReplyAuthor", ""),
94
- "ReplyBody": reply.get("ReplyBody", ""),
95
- "ReplyTimestamp": reply.get("ReplyTimestamp", ""),
96
- "ReplyUpvotes": reply.get("ReplyUpvotes", ""),
97
- "ReplyPermalink": reply.get("ReplyPermalink", "")
98
- })
99
-
100
- comments.append({
101
- "CommentID": comment_id,
102
- "CommentAuthor": comment_author,
103
- "CommentBody": comment_body,
104
- "CommentTimestamp": comment_timestamp,
105
- "CommentUpvotes": comment_upvote,
106
- "CommentPermalink": comment_permalink,
107
- "Replies": replies
108
- })
109
 
110
  yield post_id, {
111
  "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,