在文本中发现慰问、痛苦和同理心

condolence-models的Python项目详细描述


吊唁模型

简介

condolence-models是一个用来检测吊唁和悲伤的包裹 表达,以及同情的评论。它与 EMNLP 2020论文Condolence and Empathy in Online Commmunities。在

安装

使用pip

如果安装了pip,则可以直接从中安装问题亲密度:

pip3 install condolence-models

依赖性

^{pr2}$

用法和示例

有关如何使用分类器的示例,请参见example.py。在

Note: The first time you run the code, the model parameters will need to be downloaded, which could take up significant space. The condolence and distress classifiers are about 500MB each, and the empathy classifier is about 1GB.

吊唁和遇险的界面是一样的。的接口 同理心与simpletransformers接口略有不同 更接近。在

对吊唁或痛苦进行分类。

fromcondolence_models.condolence_classifierimportCondolenceClassifiercc=CondolenceClassifier()# single string gets turned into a length-1 list# outputs probabilitiesprint("I like ice cream")print(cc.predict("I like ice cream"))# [0.11919236]# multiple stringsprint(["I'm so sorry for your loss.","F","Tuesday is a good day of the week."])print(cc.predict(["I'm so sorry for your loss.","F","Tuesday is a good day of the week."]))# [0.9999901  0.8716224  0.20647633]

同理心分类。

fromcondolence_models.empathy_classifierimportEmpathyClassifierec=EmpathyClassifier(use_cuda=True,cuda_device=2)# list of lists# first item is target, second is observer# regression output on scale of 1 to 5print([["","Yes, but wouldn't that block the screen?"]])print(ec.predict([["","Yes, but wouldn't that block the screen?"]]))# [1.098]

联系人

周乃田(naitian@umich.edu

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

推荐PyPI第三方库


热门话题
java如何将cassandra中的行数据转换为与列相关的嵌套json   java如何使用jcr XPath在jcr:content/@jcr:data中搜索?   java在使用openCV进行安卓开发时如何利用手机的广角镜头   java解析扩展了接口,结束了一个潜在的无限循环   位置服务的@Override方法中存在java Android应用程序错误   java本地线程的用途和需求是什么   具有左右子访问的java节点树遍历   java验证JsonWebToken签名   JUL日志处理程序中的java日志记录   嵌入式Java读取给定时间段的串行数据。   java有没有办法从多个URL获取多个图像?   java线程通过等待intent阻止自己发送intent   java Spring MVC解析多部分内容请求   java JPA/Hibernate静态元模型属性未填充NullPointerException   java格式错误的字符(需要引号,得到I)~正在处理   java为什么PrintWriter对象抛出FileNotFoundException?   java Neo4j未正确保存标签   java IE不加载图像