在文本中发现慰问、痛苦和同理心
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)
- 项目
标签: