[U] Rename, restructure

This commit is contained in:
Hykilpikonna
2021-11-24 21:34:34 -05:00
parent 3c2ad5462a
commit cc90af631d
2 changed files with 46 additions and 35 deletions
+6 -6
View File
@@ -99,7 +99,7 @@ def get_user_popularity_ranking(user: str) -> int:
@dataclass()
class Sample:
class UserSample:
"""
This is a data class storing our different samples.
"""
@@ -147,7 +147,7 @@ def select_user_sample() -> None:
sample = random.sample(filtered, 500)
# Save
write(file, json_stringify(Sample(most_popular, sample, get_english_news_channels())))
write(file, json_stringify(UserSample(most_popular, sample, get_english_news_channels())))
def get_english_news_channels() -> list[str]:
@@ -202,16 +202,16 @@ def filter_news_channels() -> None:
write(f'{USER_DIR}/processed/sample.json', json_stringify(sample))
def load_user_sample() -> Sample:
def load_user_sample() -> UserSample:
"""
Load the selected sample
:return: None
"""
j = json.loads(read(f'{USER_DIR}/processed/sample.json'))
return Sample([ProcessedUser(*u) for u in j['most_popular']],
[ProcessedUser(*u) for u in j['random']],
j['english_news'])
return UserSample([ProcessedUser(*u) for u in j['most_popular']],
[ProcessedUser(*u) for u in j['random']],
j['english_news'])
class Posting(NamedTuple):