Skip to main content

Infer moral appeals from text

Project description

PyPI version

Introduction

vMFD is an easy-to-use Python package for inferring moral appeals from text. It extends eMFD through word embedding and yields superior performance.

Quick start

Install

After cloning this repo to your computer, go to the directory where setup.py resides and use the following command to install the package:

pip install vMFD

Download data

The package relies on a pre-calculated data frame that needs to be downloaded. You can use the following command in a Python console or notebook:

import vMFD
vMFD.download_data("word_moral_appeals_googlenews")

You can replace word_moral_appeals_googlenews with other categories. Currently, the following categories are supported:

Category name Note
word_moral_appeals_googlenews Based on pre-trained embedding by Google. The embedding contains 300-dimensional vectors for 3 million words and phrases. See https://code.google.com/archive/p/word2vec/ for details.

Calculate moral intuitions

Once the data is downloaded, you can calculate the moral intuitions of any text.

import vMFD

vo = vMFD.vMFD()

# Only calculate the valence
vo.calculate_valence("Trump is the best president")

# Calculate all metrics
vo.calculate_metrics("Trump is the best president")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vMFD-0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

vMFD-0.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file vMFD-0.2.tar.gz.

File metadata

  • Download URL: vMFD-0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for vMFD-0.2.tar.gz
Algorithm Hash digest
SHA256 9c06058a98b0d9a0791460725197ac36c2636a0b2e59b76f354c8c49af5b170a
MD5 733eae5524c61d3dd1b5319dc9c95a39
BLAKE2b-256 7a04391eb6345b810247884e57531cf350340960b73411a7fc78cc5717e13328

See more details on using hashes here.

Provenance

File details

Details for the file vMFD-0.2-py3-none-any.whl.

File metadata

  • Download URL: vMFD-0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for vMFD-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6967db4e22914208584a9e2eb561311b45147e785f557966033211e8a10d645
MD5 aaa0c546e1574b91d40cf7801cfb6895
BLAKE2b-256 3109eae6dfdde53f3323805249d47c3f893de46b96848eb9a2acab9d67485030

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page