From 4e84de3fcaee95b906cef99a27448a081d24db18 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Wed, 24 Nov 2021 11:19:59 -0500 Subject: [PATCH] [+] Add news channels to sample --- src/main.py | 5 +++-- src/process/twitter_process.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index 17580da..a27afff 100644 --- a/src/main.py +++ b/src/main.py @@ -21,8 +21,8 @@ if __name__ == '__main__': #################### # Data collection - Step C1.2 - # Download all tweets from twitternews - download_all_tweets(api, 'twitternews') + # Download all tweets from TwitterNews + download_all_tweets(api, 'TwitterNews') ##################### # Data processing - Step P1 @@ -35,6 +35,7 @@ if __name__ == '__main__': # (After step P1) Select 500 most popular users and 500 random users who meet a particular # criteria as our sample, also find news channels # select_user_sample() + get_english_news_channels() # Just curious, who are the 20 most popular individuals on twitter? # print(tabulate(((u.username, u.popularity) for u in load_user_sample().most_popular[:20]), diff --git a/src/process/twitter_process.py b/src/process/twitter_process.py index 04772dd..dea068b 100644 --- a/src/process/twitter_process.py +++ b/src/process/twitter_process.py @@ -102,6 +102,7 @@ class Sample: """ most_popular: list[ProcessedUser] random: list[ProcessedUser] + english_news: list[str] def select_user_sample() -> None: @@ -143,12 +144,12 @@ def select_user_sample() -> None: sample = random.sample(filtered, 500) # Save - write(file, json_stringify(Sample(most_popular, sample))) + write(file, json_stringify(Sample(most_popular, sample, get_english_news_channels()))) -def get_news_channels() -> list[str]: +def get_english_news_channels() -> list[str]: """ - Find news channels + Find news channels that post in English Run this after download_all_tweets(api, 'TwitterNews')