Skip to main content

Basic usage script for dictionary-based sentiment analysis. Intended use with labMT data

Project description

TL;DR a simple labMT usage script

This script uses the language assessment by Mechanical Turk (labMT) word list to score the happiness of a corpus. The labMT word list was created by combining the 5000 words most frequently appearing in four sources: Twitter, the New York Times, Google Books, and music lyrics, and then scoring the words for sentiment on Amazon’s Mechanical Turk. The list is described in detail in the publication Dodds’ et al. 2011, PLOS ONE, “Temporal Patterns of Happiness and Information in a Global-Scale Social Network: Hedonometrics and Twitter.”

Given two corpora, the script “storylab.py” creates a word-shift graph illustrating the words most responsible for the difference in happiness between the two corpora. The corpora should be large (e.g. at least 10,000 words) in order for the difference to be meaningful, as this is a bag-of-words approach. As an example, a random collection of English tweets from both Saturday January 18 2014 and Tuesday January 21 2014 are included in the “example” directory. They can be compared by moving to the test directory, using the command

python example.py example-shift.html

and opening the file example-shift.html in a web browser. For an explanation of the resulting plot, please visit

http://www.hedonometer.org/shifts.html

Installation

Cloning the github directly is recommended, i.e.

git clone https://github.com/andyreagan/labMT-simple.git

and then installing locally using

sudo python setup.py install

Tests can be run by navigating to the test directory, and running

python test.py

which will compare the two days in test/data and print test.html which shifts them, allowing for a changable lens.

This repository can also be installed using pip

pip install labMTsimple

in which case you can download the tests from github and run them, if desired.

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

labMTsimple-2.8.7.tar.gz (3.7 MB view details)

Uploaded Source

File details

Details for the file labMTsimple-2.8.7.tar.gz.

File metadata

  • Download URL: labMTsimple-2.8.7.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/2.7.16

File hashes

Hashes for labMTsimple-2.8.7.tar.gz
Algorithm Hash digest
SHA256 e82eeed95053c0489c3c853e54ce53321bbcf27ac71c08baa4c645cc676e296f
MD5 1e9bee0ed0aea6fb62c7d0916b2ed78e
BLAKE2b-256 7f781ed39da8414023609893b6c1b252d6dec344764762ab174e869429041370

See more details on using hashes here.

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