Python中使用字典方法的情感分析
pysentiment2的Python项目详细描述
pyemotion公司
概述
这是一个字典框架下的情感分析库。 图书馆提供两本词典,分别是《哈佛IV-4》和 Loughran和McDonald金融情绪词典 一般和金融情绪分析词典。在
另请参见http://www.wjh.harvard.edu/~inquirer/和https://www3.nd.edu/~mcdonald/Word_Lists.html。在
简介
Positive
和Negative
是正负集中的单词数。在
Polarity
和{
入门
安装pysentiment2
:
pip install pysentiment2
一个简单的例子:
^{pr2}$使用
要使用Harvard IV-4字典,请创建HIV4
类的实例
importpysentiment2aspshiv4=ps.HIV4()tokens=hiv4.tokenize(text)# text can be tokenized by other ways# however, dict in HIV4 is preprocessed# by the default tokenizer in the libraryscore=hiv4.get_score(tokens)
HIV4
是pysentiment2.base.BaseDict
的子类。BaseDict
可以由继承
实现init_dict
来初始化字典的_posset
和{
同样,要使用Loughran和McDonald字典:
importpysentiment2aspslm=ps.LM()tokens=lm.tokenize(text)score=lm.get_score(tokens)
链接
作者
pysentiment2
由Nick DeRobertis创建,但基于韩志超的pysentiment
。GNU GPL许可证。在
- 项目
标签: