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

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广播接收器未检测到按键事件   java不为特定列更改创建修订   java采用了更实用的方法   java桌面窗格HTML呈现   java处理internet连接丢失   java在调整JFrame的大小时,如何防止JTable的列调整大小?   如何用Java中的“Scanner.hasNext”完成程序   具有模块名称的java停止IntelliJ项目工具窗口?   执行已编译的Rails-Warbler JAR文件时发生java加载错误   java Spring数据redis存储库不支持集合查询?   每个客户端的java队列请求   获取Java中的JSON嵌套数组元素   java GWT,Vaadin ConcurrentModificationException   firebase存储中的java在保存照片之前,我需要发送两次照片   JavaSpringEleaf如何在容器外使用变量