python住房情绪_用python量化情绪分析

本文介绍了使用Python进行情感分析的方法,包括VADER库和Stanford NLP的情感评分。通过示例展示了如何分析文本中关于住房的情绪,从最消极到最积极的评分。
摘要由CSDN通过智能技术生成

我知道几种方法:维德将分数作为分级返回(介于0和1之间)

Stanford NLP返回一个分类(即0、1、2、3)。在

NLTK方法:from nltk.sentiment.vader import SentimentIntensityAnalyzer as sia

sentences = ['This is the worst lunch I ever had!',

'This is the best lunch I have ever had!!',

'I don\'t like this lunch.',

'I eat food for lunch.',

'Red is a color.',

'A really bad, horrible book, the plot was .']

hal = sia()

for sentence in sentences:

print(sentence)

ps = hal.polarity_scores(sentence)

for k in sorted(ps):

print('\t{}: {:>1.4}'.format(k, ps[k]), end=' ')

print()

输出示例:

^{pr2}$

斯坦福NLP,Python方法:

(请注意,这种方式需要启动CoreNLP服务器的一个实例来运行,例如:java -mx1g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNL

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值