Datasets:
Upload reddit_climate_comment.py
Browse files- 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 |
-
|
| 84 |
|
| 85 |
comment = {
|
| 86 |
"CommentID": comment_id,
|
| 87 |
-
"CommentAuthor":
|
| 88 |
-
"CommentBody":
|
| 89 |
-
"CommentTimestamp":
|
| 90 |
-
"CommentUpvotes":
|
| 91 |
-
"CommentPermalink":
|
| 92 |
"replies": [] # Initialize empty list for replies
|
| 93 |
}
|
| 94 |
|
| 95 |
-
# Get replies for the current comment
|
| 96 |
-
|
| 97 |
-
for _, reply_data in
|
| 98 |
reply = {
|
| 99 |
-
"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 |
+
|