Python中使用字典方法的情感分析

pysentiment2的Python项目详细描述


pyemotion公司

概述

这是一个字典框架下的情感分析库。 图书馆提供两本词典,分别是《哈佛IV-4》和 Loughran和McDonald金融情绪词典 一般和金融情绪分析词典。在

另请参见http://www.wjh.harvard.edu/~inquirer/https://www3.nd.edu/~mcdonald/Word_Lists.html。在

简介

PositiveNegative是正负集中的单词数。在

Polarity和{}的计算方法与Lydia系统相同。 另请参见http://www.cs.sunysb.edu/~skiena/lydia/

入门

安装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)

HIV4pysentiment2.base.BaseDict的子类。BaseDict可以由继承 实现init_dict来初始化字典的_posset和{} 计算术语的“正”或“负”分数。在

同样,要使用Loughran和McDonald字典:

importpysentiment2aspslm=ps.LM()tokens=lm.tokenize(text)score=lm.get_score(tokens)

链接

documentation here.

作者

pysentiment2由Nick DeRobertis创建,但基于韩志超的pysentiment。GNU GPL许可证。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
图像处理Java 8 ImageIO在Linux中无法正确读取JPEG   spring如何用Java 1.4兼容版本替换@Resource注释   java Http请求参数类型传播   在web浏览器中看不到Java Maven Tomcatplugin web应用程序   jvm在Java中使用直接内存的目的是什么?   如何从列表转换为字符串java   java setAdapter gridview发送上下文   SwingJava。方法上的lang.NullPointerException   java什么是shell脚本、makefile和ant文件   当使用getGraphics()方法时,java JPanel图形会闪烁   java如何将迭代转换为递归?   java为什么我的抽屉菜单在同一个XML上有ConstraintLayout时没有响应?   java如何在图像上画一个圆?   Android studio:Rabbitmq:Error:java。lang.ClassNotFoundException:类io。千分尺。果心仪器找不到仪表注册表