You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: script.py
+4-2
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,7 @@
102
102
word_count=collections.Counter()
103
103
104
104
# Analyze comments for wholesome words
105
+
comment_count=0
105
106
forcommentinapi_comments:
106
107
# Clean and tokenize comment
107
108
comment_text=re.sub(
@@ -113,6 +114,7 @@
113
114
iftokeninwholesome_set:
114
115
wholesome_count+=1
115
116
word_count[token] +=1
117
+
comment_count+=1
116
118
117
119
# Construct table of wholesome words and counts
118
120
table_rows= [
@@ -122,9 +124,9 @@
122
124
123
125
# Construct reply text with wholesome count and table
124
126
if'!uwucheckself'inincoming_comment.body.lower():
125
-
reply_text=f'The number of wholesome occurrences in your recent 300 comments is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
127
+
reply_text=f'The number of wholesome occurrences in your recent {comment_count} comments is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
126
128
else:
127
-
reply_text=f'The number of wholesome occurrences in the recent 300 comments of u/{user_name} is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
129
+
reply_text=f'The number of wholesome occurrences in the recent {comment_count} comments of u/{user_name} is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
0 commit comments