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

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如何删除使用Solr从Word文件提取的文本中的大量“\n”?   java如何使用Rest模板创建包含变量的URL?   java Arquillian测试在JBoss 7.1和vanilla JBoss kitchensink示例中执行失败   用Java怎么说。jar从JavaScript传递非字符串参数   java Maven JAR模块依赖于WAR中的类   java libgdx如何检测冲突?   在jenkins声明性管道中包含空格的java Maven参数   安卓在Java中使用静态工厂方法和常量进行泛化   JavaGWT/Gradle项目示例。   java springhibernate事务性不回滚   用于匹配特殊模式的java正则表达式   java如何检查是否抛出异常   java JAXB解组树结构