对上市公司公告关键词数据分析

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37195257/article/details/85028943

前文已经全部爬取上市公司公告,https://blog.csdn.net/qq_37195257/article/details/85015987

# coding: utf-8
#coded by 伊玛目的门徒

from pylab import mpl

mpl.rcParams['font.sans-serif'] = ['SimHei']



import jieba
txt= open('test.txt','r').read()

words = jieba.lcut(txt)     # 使用精确模式对文本进行分词

counts = {}

for word in words:
    if len(word) == 1:    # 单个词语不计算在内
        continue
    else:
        counts[word] = counts.get(word, 0) + 1    # 遍历所有词语,每出现一次其对应的值加 1



print (counts)





items = list(counts.items())
print (items)
items.sort(key=lambda x: x[1], reverse=True)    # 根据词语出现的次数进行从大到小排序        # .


word_list=[]
count_list=[]

for i in range(0,20):
    word, count = items[i]
    word_list.append(word)
    count_list.append(count)
    print("{0:<5}{1:>5}".format(word, count))



import matplotlib.pyplot as plt


plt.bar(range(len(count_list)), count_list)

plt.xlabel(word_list)


plt.show()

频率最高词排序:

关于    4527
公告    4356
股份    2155
2018  1628
会议    1353
独立    1316
公司    1275
临时    1156
董事会   1076
意见    1006
决议     953
有限公司   942
董事     934
股东大会   778
股东     725
事项     617
资金     602
科技     573
部分     558
交易     510

图:

另外说一下,报告度最高的个股是 云南白药

猜你喜欢

转载自blog.csdn.net/qq_37195257/article/details/85028943