python產生職業要求詞雲

來源:互聯網
上載者:User

標籤:port   index   creat   logs   plt   jobs   img   image   dex   

接著上篇的說的,爬取了大資料相關的職位資訊,http://www.17bigdata.com/jobs/。

# -*- coding: utf-8 -*-"""Created on Thu Aug 10 07:57:56 2017@author: lenovo"""from wordcloud import WordCloudimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport jiebadef cloud(root,name,stopwords):    filepath = root +‘\\‘ + name    f = open(filepath,‘r‘,encoding=‘utf-8‘)    txt = f.read()    f.close()    cut = jieba.cut(txt)    words = []    for i in cut:        words.append(i)    df = pd.DataFrame({‘words‘:words})    s= df.groupby(df[‘words‘])[‘words‘].agg([(‘size‘,np.size)]).sort_values(by=‘size‘,ascending=False)    s = s[~s.index.isin(stopwords[‘stopword‘])].to_dict()    wordcloud = WordCloud(font_path =r‘E:\Python\machine learning\simhei.ttf‘,background_color=‘black‘)    wordcloud.fit_words(s[‘size‘])    plt.imshow(wordcloud)    pngfile = root +‘\\‘ + name.split(‘.‘)[0] + ‘.png‘    wordcloud.to_file(pngfile)    import os jieba.load_userdict(r‘E:\Python\machine learning\NLPstopwords.txt‘)stopwords = pd.read_csv(r‘E:\Python\machine learning\StopwordsCN.txt‘,encoding=‘utf-8‘,index_col=False)for root,dirs,file in os.walk(r‘E:\職位資訊‘):    for name in file:        if name.split(‘.‘)[-1]==‘txt‘:            print(name)            cloud(root,name,stopwords)        

詞云:

可以看出有些雜訊詞沒能被去除,比如相關、以上學曆等無效詞彙。本想通過DF判斷停用詞,但是我爬的時候沒顧及到這個問題,外加本身記錄數也不高,就沒再找職位資訊的停用詞。當然也可看出演算法和經驗是很重要的。加油

python產生職業要求詞雲

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.