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