Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/c30d04edc324f09039c1fb7d07a2b7ca to your computer and use it in GitHub Desktop.
Save dacr/c30d04edc324f09039c1fb7d07a2b7ca to your computer and use it in GitHub Desktop.
display examples keywords frequency cloud tags graph / published by https://github.com/dacr/code-examples-manager #5ecc1661-bb03-40c5-af6f-6d95941b0855/d5b92297e95db10c18780bd6f60b38edf2036d46
#!/usr/bin/env python3
## summary : display examples keywords frequency cloud tags graph
## keywords : python, examples, keywords
## publish : gist, corporate
## authors : David Crosson
## license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
## id : 5ecc1661-bb03-40c5-af6f-6d95941b0855
## created-on : 2020-10-06T15:00:25Z
## managed-by : https://github.com/dacr/code-examples-manager
## execution : python 3 with pip requirements (numpy,matplotlib,wordcloud) 'python3 scriptname.sc'
## run-with : python3 $file
# apt install python3-pip
# pip3 install numpy
# pip3 install matplotlib
# pip3 install wordcloud
# python3 cem-word-cloud.py
import numpy as np
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import subprocess
text = subprocess.getoutput("find .. -type f -exec egrep '^[-/# ]+keywords : ' {} \; | cut -d ':' -f 2 | tr -d ,")
wc = WordCloud(
width=1200,
height=800,
background_color="white",
repeat=False,
regexp=r"[-_a-zA-Z0-9]+",
collocations=False,
normalize_plurals=False,
colormap="tab10",
max_words=500
)
wc.generate(text)
plt.axis("off")
plt.imshow(wc, interpolation="bilinear")
plt.tight_layout()
plt.show()
@dacr
Copy link
Author

dacr commented Oct 7, 2020

Yes first python script published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment