Python约=武侠小说中的功夫,功夫分门别类,Anaconda类似于功夫中的“独孤九剑”。
庞大的可扩展的第三方平台+可破各种难题的库+灵活自由的Jupyter...
用Jupyter先简单实现一个文字意思分析。
以川普的就职演讲为例:http://edition.cnn.com/2017/01/20/politics/trump-inaugural-address/
第一步,导入要分析的文章:
speech_text = '''这里是要分析的文章'''
speech = speech_text.lower().split()
第二步,导入字典
dic = {}
for word in speech:
if word not in dic:
dic[word] = 1
else:
dic[word] = dic[word] + 1
dic.items()
第三步:分析所有单词出现的频率
import operator
swd = sorted(dic.items(), key = operator.itemgetter(1), reverse=True)
swd
一大推介词...
第四步:拿掉介词
from nltk.corpus import stopwords
stop_words = stopwords.words('English')
#stop_words
for k,v in swd:
if k not in stop_words:
print(k,v)
成了,看看川普口中的词,果然口口声声“爱国”啊...