mirror of
https://github.com/StefBuwalda/whatsapp-wordcloud.git
synced 2025-10-29 18:59:58 +00:00
refactoring
This commit is contained in:
@@ -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
|
||||
@@ -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))
|
||||
Reference in New Issue
Block a user