[+] Create function to load tweet of a user

This commit is contained in:
Hykilpikonna
2021-11-23 20:34:48 -05:00
parent 65df10e3c2
commit c91ac3433d
+13
View File
@@ -1,3 +1,4 @@
import os
import random
from dataclasses import dataclass
from typing import NamedTuple
@@ -210,6 +211,18 @@ def process_tweets(tweets_dir: str = './data/twitter/user-tweets/') -> None:
debug(f'Processed: {filename}')
def load_tweets(tweets_dir: str, username: str) -> list[Posting]:
"""
Load tweets for a specific user
:param tweets_dir: Tweets directory
:param username: User's screen name
:return: User's processed tweets
"""
return [Posting(*p) for p in json.loads(read(
os.path.join(tweets_dir, f'processed/{username}.json')))]
def is_covid_related(text: str) -> bool:
"""
Is a tweet / article covid-related. Currently, this is done through keyword matching. Even