diff --git a/config.py b/applications/wordcloud.py similarity index 69% rename from config.py rename to applications/wordcloud.py index 8985107..0c8cc2b 100644 --- a/config.py +++ b/applications/wordcloud.py @@ -1,4 +1,6 @@ from wordcloud import WordCloud # type: ignore +from backend.process_data import frequency_dictionary + wordcloud = WordCloud( width=800, @@ -14,3 +16,8 @@ wordcloud = WordCloud( contour_color="steelblue", # Outline color (when using contour_width) contour_width=1, # For consistent layout between runs ) + +for author in frequency_dictionary.keys(): + freq_dict = frequency_dictionary.get(author) + image = wordcloud.generate_from_frequencies(freq_dict) # type: ignore + image.to_file(f"output/{author}.png") # type: ignore diff --git a/functions.py b/backend/functions.py similarity index 100% rename from functions.py rename to backend/functions.py diff --git a/run.py b/backend/process_data.py similarity index 64% rename from run.py rename to backend/process_data.py index 879fe68..d6ab161 100644 --- a/run.py +++ b/backend/process_data.py @@ -1,6 +1,5 @@ -from config import wordcloud # type: ignore from os import makedirs -from functions import ( +from backend.functions import ( processRawMessages, processMessageList, ) @@ -20,10 +19,10 @@ makedirs("output", exist_ok=True) test = processRawMessages(chat) +frequency_dictionary: dict[str, dict[str, int]] = {} + for author in test.keys(): + frequency_dictionary[author] = {} messageList = test.get(author) if messageList: - wordList = processMessageList(messageList) - freq_dict = Counter(wordList) - image = wordcloud.generate_from_frequencies(freq_dict) # type: ignore - image.to_file(f"output/{author}.png") # type: ignore + frequency_dictionary[author] = Counter(processMessageList(messageList))