Skip to content

Commit

Permalink
Add self-referential example
Browse files Browse the repository at this point in the history
  • Loading branch information
naslundx committed Aug 23, 2024
1 parent 9881590 commit 3433701
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/selfreferential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import re
from pathlib import Path

from wrdcld import make_word_cloud

FOLDER_PATH = Path("wrdcld")

all_text = ""
for filename in os.listdir(FOLDER_PATH):
if filename.endswith(".py"):
with open(FOLDER_PATH / filename, "r", encoding="utf-8") as f:
all_text += f.read()

cleaned_text = re.sub(r"[^a-zA-Z0-9_\s]", " ", all_text)
all_words = cleaned_text.split()


img = make_word_cloud(
all_words=all_words,
minimum_font_size=5,
word_padding=3,
)

img.show()

0 comments on commit 3433701

Please sign in to comment.