refactoring

This commit is contained in:
2025-04-18 17:48:05 +02:00
parent d75536b137
commit d2d7733c35
3 changed files with 12 additions and 6 deletions

View File

@@ -1,4 +1,6 @@
from wordcloud import WordCloud # type: ignore from wordcloud import WordCloud # type: ignore
from backend.process_data import frequency_dictionary
wordcloud = WordCloud( wordcloud = WordCloud(
width=800, width=800,
@@ -14,3 +16,8 @@ wordcloud = WordCloud(
contour_color="steelblue", # Outline color (when using contour_width) contour_color="steelblue", # Outline color (when using contour_width)
contour_width=1, # For consistent layout between runs 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

View File

@@ -1,6 +1,5 @@
from config import wordcloud # type: ignore
from os import makedirs from os import makedirs
from functions import ( from backend.functions import (
processRawMessages, processRawMessages,
processMessageList, processMessageList,
) )
@@ -20,10 +19,10 @@ makedirs("output", exist_ok=True)
test = processRawMessages(chat) test = processRawMessages(chat)
frequency_dictionary: dict[str, dict[str, int]] = {}
for author in test.keys(): for author in test.keys():
frequency_dictionary[author] = {}
messageList = test.get(author) messageList = test.get(author)
if messageList: if messageList:
wordList = processMessageList(messageList) frequency_dictionary[author] = Counter(processMessageList(messageList))
freq_dict = Counter(wordList)
image = wordcloud.generate_from_frequencies(freq_dict) # type: ignore
image.to_file(f"output/{author}.png") # type: ignore