import jieba
import matplotlib.pyplot as plt
import wordcloud
from wordcloud import WordCloud,ImageColorGenerator,STOPWORDS
import numpy as np
from PIL import Image
def useJieba():
mystr = "小姐姐,我看你挺能睡的,睡我好不好"
mystr_list = jieba.cut(mystr)
mystr_list2 = jieba.cut_for_search(mystr)
print(mystr_list)
print("/".join(mystr_list))
print("/".join(mystr_list2))
textfile=open("workinfo.txt", mode='r', encoding='utf-8').read()
textfile=textfile.replace("span","").replace("style","").replace("font","").replace("nbsp","")
textfile=textfile.replace("line","").replace("height","").replace("color","").replace("family","")
textfile=textfile.replace("size","").replace("宋体","").replace("rgb","").replace("white","")
textfile=textfile.replace("space","").replace("normal","").replace("backgroud","").replace("14px","")
textfile=textfile.replace("br","").replace("岗位","").replace("职责","").replace("0px","")
textfile=textfile.replace("Microsoft","").replace("YaHei","").replace("margin","").replace("top","")
textfile=textfile.replace("以上","").replace("上学","")
wordlist=jieba.cut_for_search(textfile)
space_list=" ".join(wordlist)
backgroud=np.array(Image.open("2.jpg"))
mywordcloud=WordCloud(width=1400, height=700,background_color="black",
mask=backgroud,
max_words=200,
stopwords=STOPWORDS,
font_path="simkai.ttf",
max_font_size=200,
random_state=50,
scale=2).generate(space_list)
plt.imshow(mywordcloud)
plt.axis("off")
plt.show()