cathw commited on
Commit
68da27e
·
verified ·
1 Parent(s): 2cb9642

Upload reddit_climate_comment.py

Browse files
Files changed (1) hide show
  1. reddit_climate_comment.py +11 -10
reddit_climate_comment.py CHANGED
@@ -80,23 +80,23 @@ class NewDataset(GeneratorBasedBuilder):
80
  # Extract unique comments
81
  unique_comment_ids = group['CommentID'].unique()
82
  for comment_id in unique_comment_ids:
83
- comment_row = group[group['CommentID'] == comment_id].iloc[0]
84
 
85
  comment = {
86
  "CommentID": comment_id,
87
- "CommentAuthor": comment_row['CommentAuthor'],
88
- "CommentBody": comment_row['CommentBody'],
89
- "CommentTimestamp": comment_row['CommentTimestamp'],
90
- "CommentUpvotes": comment_row['CommentUpvotes'],
91
- "CommentPermalink": comment_row['CommentPermalink'],
92
  "replies": [] # Initialize empty list for replies
93
  }
94
 
95
- # Get replies for the current comment
96
- replies_data = group[group['CommentID'] == comment_id]
97
- for _, reply_data in replies_data.iterrows():
98
  reply = {
99
- "ReplyID": str(reply_data['ReplyID']),
100
  "ReplyAuthor": reply_data['ReplyAuthor'],
101
  "ReplyBody": reply_data['ReplyBody'],
102
  "ReplyTimestamp": reply_data['ReplyTimestamp'],
@@ -120,3 +120,4 @@ class NewDataset(GeneratorBasedBuilder):
120
  "post_permalink": post_permalink,
121
  "comments": comments
122
  }
 
 
80
  # Extract unique comments
81
  unique_comment_ids = group['CommentID'].unique()
82
  for comment_id in unique_comment_ids:
83
+ comment_data = group[group['CommentID'] == comment_id].iloc[0]
84
 
85
  comment = {
86
  "CommentID": comment_id,
87
+ "CommentAuthor": comment_data['CommentAuthor'],
88
+ "CommentBody": comment_data['CommentBody'],
89
+ "CommentTimestamp": comment_data['CommentTimestamp'],
90
+ "CommentUpvotes": comment_data['CommentUpvotes'],
91
+ "CommentPermalink": comment_data['CommentPermalink'],
92
  "replies": [] # Initialize empty list for replies
93
  }
94
 
95
+ # Get all replies for the current comment
96
+ reply_group = group[group['CommentID'] == comment_id]
97
+ for _, reply_data in reply_group.iterrows():
98
  reply = {
99
+ "ReplyID": reply_data['ReplyID'],
100
  "ReplyAuthor": reply_data['ReplyAuthor'],
101
  "ReplyBody": reply_data['ReplyBody'],
102
  "ReplyTimestamp": reply_data['ReplyTimestamp'],
 
120
  "post_permalink": post_permalink,
121
  "comments": comments
122
  }
123
+