Skip to main content

Basic usage script for LabMT1.0 dataset

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

labMT-simple
============

TL;DR
a simple labMT usage script


a python module for using the labMT1.0 dataset

no dependencies, unless using the plot function
(then we use matplotlib)

Usage
-----

The Python script test.py uses this module to test a subsample of Twitter data:
```python
## set up
from storyLab import *
labMT,labMTvector,labMTwordList = emotionFileReader(returnVector=True)

## take a look at these guys
print labMT['laughter']
print labMTvector[0:5]
print labMTwordList[0:5]

## test shift a subsample of two twitter days
import codecs ## handle utf8
f = codecs.open("test/01.02.14.txt","r","utf8")
saturday = f.read()
f.close()
f = codecs.open("test/04.02.14.txt","r","utf8")
tuesday = f.read()
f.close()

## compute valence score
saturdayValence = emotion(saturday,labMT)
tuesdayValence = emotion(tuesday,labMT)
print 'the valence of {0} is {1}'.format('saturday',saturdayValence)
print 'the valence of {0} is {1}'.format('tuesday',tuesdayValence)

## compute valence score and return frequency vector for generating wordshift
saturdayValence,saturdayFvec = emotion(saturday,labMT,shift=True,happsList=labMTvector)
tuesdayValence,tuesdayFvec = emotion(tuesday,labMT,shift=True,happsList=labMTvector)

## make a shift: shift(values,ref,comp)
shiftMag,shiftType = shift(labMTvector,saturdayFvec,tuesdayFvec)
## take the absolute value of the shift magnitude
shiftMagAbs = map(abs,shiftMag)

## sort them both
indices = sorted(range(len(shiftMag)), key=shiftMagAbs.__getitem__, reverse=True)
sortedMag = [shiftMag[i] for i in indices]
sortedType = [shiftType[i] for i in indices]
sortedWords = [labMTwordList[i] for i in indices]

## take a peek at the top words
print indices[0:10]
print sortedMag[0:20]
print sortedType[0:20]
print sortedWords[0:20]

## print each of these to a file
f = open("test/sampleSortedMag.csv","w")
for val in sortedMag:
f.write(str(val))
f.write("\n")
f.close()

f = open("test/sampleSortedType.csv","w")
for val in sortedType:
f.write(str(val))
f.write("\n")
f.close()

f = open("test/sampleSortedWords.csv","w")
for val in sortedWords:
f.write(val)
f.write("\n")
f.close()
```

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-0.1.1.tar.gz (3.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: labMTsimple-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for labMTsimple-0.1.1.tar.gz
Algorithm Hash digest
SHA256 59133503e1bcd567b9d2314fc11b0738a9dd75a4f0e2051fe5da7df099340935
MD5 9c308b5dfe17992dde7f5feb3b36385a
BLAKE2b-256 e15103fe618f32df09f0d77e6b9bdd60f3978445033d2cc447b31ef2f901664a

See more details on using hashes here.

Supported by

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