Skip to content

Commit 8916eec

Browse files
committed
Check if Botometer might have had an error
1 parent 4e15f3a commit 8916eec

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

visualize_conversation_tree.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
import argparse
55

66
def tag_acc_if_bot(acc, checked_accounts):
7-
if acc not in checked_accounts:
7+
if acc not in checked_accounts or "error" in checked_accounts[acc]:
88
return acc
99
botometer_output = checked_accounts[acc]
10+
username = botometer_output["user"]["user_data"]["screen_name"]
1011
majority_lang = botometer_output["user"]["majority_lang"]
1112
cap_scores = botometer_output["cap"]
1213
score = cap_scores["english"] if majority_lang == "en" \
1314
else cap_scores["universal"]
1415
probability = int(score * 100)
1516
threshold = 0
1617
if probability > threshold:
17-
return f'{acc} (bot: {probability}% probability)'
18-
return acc
18+
return f'{username} (bot: {probability}% probability)'
19+
return username
1920

2021

2122
def visualize_api2(tweets, checked_accounts):
@@ -71,11 +72,14 @@ def visualize_conversation(conversation_json_file):
7172

7273
if __name__ == '__main__':
7374
parser = argparse.ArgumentParser(
74-
usage="%(prog)s [FILE]...",
75-
description='Visualise the tree of the conversation, whose root is the original tweet and other nodes are retweets and replies'
76-
)
75+
description=("Visualise the tree of the conversation,"
76+
"whose root is the original tweet's author"
77+
"and other nodes are the retweeters and authors of replies")
78+
)
7779
parser.add_argument('conversation_files', metavar='[FILE]', type=str, nargs='+',
78-
help='one or more json files consisting of the whole conversation associated with a Tweet')
80+
help=("one or more json files, each file consisting of"
81+
"the whole conversation associated with a Tweet")
82+
)
7983

8084
args = parser.parse_args()
8185
for filename in args.conversation_files:

0 commit comments

Comments
 (0)