-
Notifications
You must be signed in to change notification settings - Fork 0
/
wcloud.py
25 lines (19 loc) · 898 Bytes
/
wcloud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS
def WCLOUD(stpwrd, imgfname="wordcloud.png", w=400, h=400):
# Lecture des tweets
file = open("res.csv", "r")
text = ""
for line in file.readlines():
text += line.split(",")[2] + " "
# Mots à ne pas prendre en compte par le systeme
g_stopwords = stpwrd
# optionally add: stopwords=STOPWORDS and change the arg below
def generate_wordcloud(text):
wordcloud = WordCloud(font_path='Roboto_Slab/RobotoSlab-Regular.ttf', # la font utilisé
relative_scaling=1,
width=w, # taille de l'image finale, prédit la résolution des mots aussi
height=h,
stopwords=g_stopwords).generate(text)
plt.imsave(imgfname, wordcloud)
generate_wordcloud(text)