|
4 | 4 | import argparse |
5 | 5 |
|
6 | 6 | 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]: |
8 | 8 | return acc |
9 | 9 | botometer_output = checked_accounts[acc] |
| 10 | + username = botometer_output["user"]["user_data"]["screen_name"] |
10 | 11 | majority_lang = botometer_output["user"]["majority_lang"] |
11 | 12 | cap_scores = botometer_output["cap"] |
12 | 13 | score = cap_scores["english"] if majority_lang == "en" \ |
13 | 14 | else cap_scores["universal"] |
14 | 15 | probability = int(score * 100) |
15 | 16 | threshold = 0 |
16 | 17 | if probability > threshold: |
17 | | - return f'{acc} (bot: {probability}% probability)' |
18 | | - return acc |
| 18 | + return f'{username} (bot: {probability}% probability)' |
| 19 | + return username |
19 | 20 |
|
20 | 21 |
|
21 | 22 | def visualize_api2(tweets, checked_accounts): |
@@ -71,11 +72,14 @@ def visualize_conversation(conversation_json_file): |
71 | 72 |
|
72 | 73 | if __name__ == '__main__': |
73 | 74 | 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 | + ) |
77 | 79 | 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 | + ) |
79 | 83 |
|
80 | 84 | args = parser.parse_args() |
81 | 85 | for filename in args.conversation_files: |
|
0 commit comments