#%%
import pandas as pd
import numpy as np
import os
import re
import jieba
from wordcloud import WordCloud
# from imageio import imread

def generateCloud(path,outputName="JobCloud",fontpath="simhei.ttf"):#传入单个job文件路径，统计JobName词频做词云，输出到当前路径下的outputName.jpg，fontpath为词云字体路径
    #读取文件中所有的JobName组成文本库
    oridata=pd.read_csv(path)
    NameSum=""
    for i in oridata['jobName']:
        NameSum+=" "+i
    #对文本进行分词
    NameSum= " ".join(jieba.cut(NameSum))
    #生成词云
    wordcloud = WordCloud(width=800,height=600,font_path=fontpath,background_color='white').generate(NameSum)

    #输出到当前路径下outputName.jpg
    wordcloud.to_file('../html/imgs/' + outputName + ".jpg")

#%%
#示例
# generateCloud("C:\\MyWorkSpace\\shu-innovation-project\\data\\jobs\\lagou\\北京 C++.csv")