removing quoted text
parent
5a4c8e81f6
commit
39d1aac958
11
autodrama.py
11
autodrama.py
|
@ -159,7 +159,7 @@ def analyze_comments(submission : 'Submission'):
|
|||
basedness = average_child_score - comment_score
|
||||
ranked_comments.append((basedness, comment_info))
|
||||
# Add to angriness
|
||||
score = sid_obj.polarity_scores(comment.body)['compound']
|
||||
score = sid_obj.polarity_scores(remove_quoted_text(comment.body))['compound']
|
||||
if score < -0.5:
|
||||
angry_comments.append((sid_obj.polarity_scores(comment.body)['compound'], comment_info))
|
||||
|
||||
|
@ -191,6 +191,9 @@ def analyze_comments(submission : 'Submission'):
|
|||
}
|
||||
#get_based_submissions("all", "hour", 25, True)
|
||||
|
||||
def remove_quoted_text(string):
|
||||
return '\n'.join([i for i in string.split("\n") if i == "" or i[0] != ">"])
|
||||
|
||||
def generate_comment_display_section(submissions : 'Tuple[float, Submission]', section_title, detail_display, number_to_show, show_details = True, detail_func = lambda a : a, max_len = 1000 ):
|
||||
markdown_lines = []
|
||||
if len(submissions) != 0:
|
||||
|
@ -204,7 +207,8 @@ def generate_comment_display_section(submissions : 'Tuple[float, Submission]', s
|
|||
comment_indent = ""
|
||||
|
||||
if (parent != None):
|
||||
parent_body = parent.body.replace("\n", "")
|
||||
parent_body = remove_quoted_text(parent.body)
|
||||
parent_body = parent_body.replace("\n", "")
|
||||
if len(parent_body) > max_len:
|
||||
parent_body = parent_body[0:max_len-3] + "..."
|
||||
markdown_lines.append(f"> {parent_body} ({parent.score})")
|
||||
|
@ -212,7 +216,8 @@ def generate_comment_display_section(submissions : 'Tuple[float, Submission]', s
|
|||
else:
|
||||
comment_indent = ">"
|
||||
|
||||
comment_body = comment.body.replace("\n", "")
|
||||
comment_body = remove_quoted_text(comment.body)
|
||||
comment_body = comment_body.replace("\n", "")
|
||||
if len(comment_body) > max_len:
|
||||
comment_body = comment_body[0:max_len-3] + "..."
|
||||
markdown_lines.append(f"{comment_indent} [{comment_body}](https://reddit.com{comment.permalink}) ({comment.score})")
|
||||
|
|
Loading…
Reference in New Issue