Working With REST APIs

Links

  • The Alchemy API offers a number of tools for analyzing text, including keyword extraction, and sentiment analysis. You need to register for an API key
  • The Dandelion API also supports some text analysis, including sentiment analysis. It has a free API key that you need to use the service.

Code

Example code using Alchemy API to analyze an example of the Ken Lay Email (remember that from week 4).

In Class Exercise

Create a program that will compute the average sentiment in the Enron Email Dataset for a day. Remember you are limited in the number of API calls you can make, so you shouldn't compute the sentiment for each email individually.

Print that sentiment value and the associated stock price and stock change (% increase or decrease), in a comma separated file with the format average sentiment, stock price, stock change that looks like this (note - those are not the actual prices for those dates):

1-1-1999,0.61,55.04,0.33
1-2-1999,-0.12,53.02,-0.02
Use the Ken Lay email file from Week 4 as your testing file. Eventually, this should work on all Enron email. Find your own source of historical stock data for Enron.