From 685738b5c9b863fc9157a88fa1b5e792cb25a73d Mon Sep 17 00:00:00 2001 From: Stef Date: Fri, 18 Apr 2025 18:50:01 +0200 Subject: [PATCH] Update chatgpt.py --- chatgpt.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/chatgpt.py b/chatgpt.py index 82a7955..d6336e3 100644 --- a/chatgpt.py +++ b/chatgpt.py @@ -11,25 +11,23 @@ data = word_frequency_dict TOP_N = 5 # Collect top words globally or per author -combined = Counter() +combined = Counter() # type: ignore for author in data: - combined.update(data[author]) + combined.update(data[author]) # type: ignore -top_words = [word for word, _ in combined.most_common(TOP_N)] +top_words = [word for word, _ in combined.most_common(TOP_N)] # type: ignore # Create DataFrame with only top words -df = pd.DataFrame(data).fillna(0).astype(int) -df = df.loc[df.index.intersection(top_words)] +df = pd.DataFrame(data).fillna(0).astype(int) # type: ignore +df = df.loc[df.index.intersection(top_words)] # type: ignore -# Plot heatmap -import seaborn as sns -plt.figure(figsize=(8, 5)) -sns.heatmap( +plt.figure(figsize=(8, 5)) # type: ignore +sns.heatmap( # type: ignore df, annot=True, fmt="d", cmap="YlGnBu", cbar_kws={"format": "%.0f"} ) -plt.title(f"Top {TOP_N} Word Frequencies") -plt.xlabel("Author") -plt.ylabel("Word") +plt.title(f"Top {TOP_N} Word Frequencies") # type: ignore +plt.xlabel("Author") # type: ignore +plt.ylabel("Word") # type: ignore plt.tight_layout() -plt.show() +plt.show() # type: ignore