[+] Add news channels to sample

This commit is contained in:
Hykilpikonna
2021-11-24 11:19:59 -05:00
parent dfe4410e2b
commit 4e84de3fca
2 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -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]),
+4 -3
View File
@@ -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')