Dream to Learn is shutting down...

We are very sorry to say that Dream to Learn will be shutting down as of December 28th, 2019. If you have content that you wish to keep, you should make a copy of it before that date.


2COMMENTS1RECOMMENDS

IBM Watson & AlchemyAPI - Making First Contact with R Programming Language (Part 1)

87
POSTED IN: Data Analytics & Visualization Blog

 

As Venturebeat noted in March 2015 >

 

Technology heavyweight IBM today is announcing that it has acquired AlchemyAPI, a startup with a service for making inferences on images and text using a form of trendy artificial intelligence called deep learning. The idea is to bolster the IQ of IBM’s Watson “cognitive” computing system with AlchemyAPI’s tools

 

API's are open - easy to get a key - so let's play... first post - just getting basic connection and syntax...

 

 

 

# Playing around with R Programming Language and IBM's new toolkit AlchemyAPI
# Free API key here - http://www.alchemyapi.com/api/register.html

library(httr)
library(RCurl)

# verify these work in your browser first - with your api KEY - IF NOT, you have to figure that out first.  if OK, then can proceed to R syntax for first contact...

# WORKS IN BROWSWER - http://access.alchemyapi.com/calls/url/URLGetTextSentiment?url=https://dreamtolearn.com/node/8OVIWY2C5RLZZSYD9OHCKM8AI/80&apikey={error: no user with username '{SECRET_API_KEY}' was found}
# WORKS IN BROWSER - http://access.alchemyapi.com/calls/url/URLGetTextSentiment?url=http%3A%2F%2Fwww.macrumors.com%2F2013%2F11%2F05%2Fapple-releases-itunes-11-1-3-with-equalizer-and-performance-improvements%2F&apikey={error: no user with username '{SECRET_API_KEY}' was found}&outputMode=json
# WORKS IN BROWSER - http://access.alchemyapi.com/calls/url/URLGetTextSentiment?url=http://www.thebusinessmakers.com/episodes/shows/2014/november-2014/episode-494/sridhar-sudarsan.html&apikey={error: no user with username '{SECRET_API_KEY}' was found}&outputMode=json

alchemy_url <- "http://access.alchemyapi.com/calls/url/"
api_feature <- "URLGetTextSentiment"
the_url <- "https://dreamtolearn.com/node/8OVIWY2C5RLZZSYD9OHCKM8AI/80"
api_key <- "{error: no user with username '{SECRET_API_KEY}' was found}"  # alchemy API secret key 
temp <- paste(alchemy_url,api_feature,"?url=",the_url,"&apikey=",api_key,"&outputMode=json", sep="")
temp
POST(temp)

#end of code

works!

### if it works - response like this:  
#Response [http://access.alchemyapi.com/calls/url/URLGetTextSentiment?url=https://dreamtolearn.com/node/8OVIWY2C5RLZZSYD9OHCKM8AI/80&apikey=SECRET&outputMode=json]
#Status: 200
#Content-Type: application/json
#{
#  "status": "OK",
#    "url": "https://dreamtolearn.com/node/8OVIWY2C5RLZZSYD9OHCKM8AI/80",
#    "totalTransactions": "1",
#    "language": "english",
#    "docSentiment": {
#        "score": "0.831337",
#        "type": "positive"
#    }

Interested in more content by this author?

About the Author

Ryan Anderson

Ryan Anderson

Hi! I like to play with data, analytics and hack around with robots and gadgets in my garage. Lately I've been learning about machine learning.

About this blog

Description is...<br/>Data Analytics & Visualization Blog - Generating insights from Data since 2013

Created: July 25, 2014

Englishfrançais

Up Next