# -*- coding: utf-8 -*- """ Created on Mon Nov 6 14:05:00 2017 @author: home """ from os import listdir from os.path import isfile, join import sys sys.path.append("/Volumes/NewVolume/Emotional-Arcs/tools") from dogtoys import * from json import loads from re import findall, UNICODE from labMTsimple.speedy import LabMT my_LabMT = LabMT() from labMTsimple.storyLab import * import numpy as np import matplotlib.pyplot as plt from IPython import get_ipython get_ipython().run_line_magic('matplotlib', 'inline') #%matplotlib inline from tools.bookclass import Book_raw_data import pickle import os sys.path.append('/Volumes/NewVolume/Emotional-Arcs/database') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gutenbergdb.settings') import django django.setup()
# and save a frequency file, labMT vector in keywords/[keyword] # for each keyword # we'll use most of these from json import loads import codecs import datetime import re import numpy import sys import pickle sys.path.append("/users/a/r/areagan/work/2014/03-labMTsimple/") from labMTsimple.speedy import LabMT my_LabMT = LabMT(stopVal=0.0) def tweetreader(tweettext, wordDict): replaceStrings = ['---', '--', '\'\''] for replaceString in replaceStrings: tweettext = tweettext.replace(replaceString, ' ') words = [ x.lower() for x in re.findall( r"[\w\@\#\'\&\]\*\-\/\[\=]+", tweettext, flags=re.UNICODE) ] for word in words: if word in wordDict: wordDict[word] += 1 else: wordDict[word] = 1