Skip to main content

Condolence Models

Intro

condolence-models is a package used to detect condolence and distress expressions, as well as empathetic comments. It is released with the EMNLP 2020 paper Condolence and Empathy in Online Commmunities.

Install

Use pip

If pip is installed, question-intimacy could be installed directly from it:

pip3 install condolence-models

Dependencies

python>=3.6.0
torch>=1.6.0
pytorch-transformers
markdown
beautifulsoup4
numpy
tqdm
simpletransformers
pandas
numpy

Usage and Example

See example.py for an example of how to use the classifiers.

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.

The interface for condolence and distress are the same. The interface for empathy is slightly different, to align with the simpletransformers interface more closely.

Classifying condolence or distress.

from condolence_models.condolence_classifier import CondolenceClassifier

cc = CondolenceClassifier()

# single string gets turned into a length-1 list
# outputs probabilities
print("I like ice cream")
print(cc.predict("I like ice cream"))
# [0.11919236]

# multiple strings
print(["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]

Classifying empathy.

from condolence_models.empathy_classifier import EmpathyClassifier
ec = EmpathyClassifier(use_cuda=True, cuda_device=2)

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

Contact

Naitian Zhou (naitian@umich.edu)

Metadata

Release files for condolence-models 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for condolence-models 1.0.0
File Size Uploaded Provenance Actions
condolence-models-1.0.0.tar.gz 5.7 kB Without provenance Details for condolence-models-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for condolence-models 1.0.0
File Interpreter ABI Platform Actions
condolence_models-1.0.0-py3-none-any.whl Python 3 none any Details for condolence_models-1.0.0-py3-none-any.whl

Total release size: 14.7 kB

Release files / condolence-models-1.0.0.tar.gz

Download URL condolence-models-1.0.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e12de4468954a684f10ddd3d7ca75a1656090899c3f95724ff0a66144ad3e789
BLAKE2b-256 checksum
How to use checksums
72bfd3985e3c2678ac7cd41453e29ae4ae5963120e2e6083fa835e2a1aa92d64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.8

Release files / condolence_models-1.0.0-py3-none-any.whl

Download URL condolence_models-1.0.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4061a8c9fbe82e08531589ccd5fb304939952cd091bf99eabdb7a86be8934d19
BLAKE2b-256 checksum
How to use checksums
2971fdcc7012191c6ce55a4a5a7a511d08dba038b8ec14ca42d259c551a2c910
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.8

Security for condolence-models 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page