-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathword.py
40 lines (32 loc) · 993 Bytes
/
word.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# from word import STOPWORDS
import matplotlib.pyplot as plt
import pandas as pd
from wordcloud import WordCloud, STOPWORDS
df = pd.read_csv('title_freq.csv')
df = df.rename(columns={'Unnamed: 0': 'phrase', 1: 'frequency'})
print(df)
freq = dict(zip(df['phrase'],df['frequency']))
print(freq)
stopwords = set(STOPWORDS)
# stopwords.add('s')
# stopwords.add('language')
# stopwords.add('use')
# stopwords.add('based')
# stopwords.add('model')
# stopwords.add('word')
# stopwords.add('impact')
# stopwords.add('case')
# stopwords.add('impact')
# stopwords.add('study')
# stopwords.add('causal')
# stopwords.add('graph')
wordcloud = WordCloud(width = 800, height = 800,
background_color ='white',
stopwords = stopwords,
min_font_size = 10).generate_from_frequencies(freq)
plt.figure(figsize = (8, 8), facecolor = None)
plt.imshow(wordcloud)
plt.axis("off")
plt.tight_layout(pad = 0)
plt.savefig('title.png')
plt.show()