[+] Add news channels to sample
This commit is contained in:
+3
-2
@@ -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]),
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user