MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / QuickWordCloud

Class QuickWordCloud

projects/QuickWordCloud/main.py:5–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4
5class QuickWordCloud:
6 def __init__(self, file_name="./data/test_data.txt"):
7 self.file_name = file_name
8
9 def extract_words(self):
10 all_words = ""
11 with open(self.file_name) as file:
12 data = file.read()
13 words = data.split()
14 words_lower = [w.lower() for w in words]
15 all_words += " ".join(words_lower) + " "
16 return all_words
17
18 def create_word_cloud(self, text):
19 wordcloud = WordCloud(
20 width=1600,
21 height=800,
22 background_color="white",
23 collocations=False,
24 repeat=True,
25 ).generate(text)
26
27 plt.figure(figsize=(10, 5))
28 plt.imshow(wordcloud, interpolation="bilinear")
29 plt.axis("off")
30 plt.show()
31
32
33if __name__ == "__main__":

Callers 2

main.pyFile · 0.85

Calls

no outgoing calls

Tested by 1