0

I am using Bluemix environment and Node-RED flow editor. While trying to use the feature extract node that comes built-in Node-RED for the AlchemyAPI service, I am finding it hard to use it.

I tried connecting it to the HTTP request node, HTTP response node, etc, but no result. Maybe I am not completing the connections procedure correctly?

I need this code to get Twitter news and news using AlchemyAPI news data for specific companies and also give a sentiment score to and get store in IBM HDFS.

Here is the code:

[{"id":"8bd03bb4.742fc8","type":"twitter
in","z":"5fa9e76b.a05618","twitter":"","tags":"Ashok Leyland, Tata Communication, Welspun, HCL Info,Fortis H, JSW Steel, Unichem Lab, Graphite India, D B Realty, Eveready Ind, Birla Corporation, Camlin Fine Sc, Indian Economy, Reserve Bank of India, Solar Power, Telecommunication, Telecom Regulatory Authority of India","user":"false","name":"Tweets","topic":"tweets","x":93,"y":92,"wires":[["f84ebc6a.07b14"]]},{"id":"db13f5f.f24ec08","type":"ibm hdfs","z":"5fa9e76b.a05618","name":"Dec12Alchem","filename":"/12dec_alchem","appendNewline":true,"overwriteFile":false,"x":564,"y":226,"wires":[]},{"id":"4a1ed314.b5e12c","type":"debug","z":"5fa9e76b.a05618","name":"","active":true,"console":"false","complete":"false","x":315,"y":388,"wires":[]},{"id":"f84ebc6a.07b14","type":"alchemy-feature-extract","z":"5fa9e76b.a05618","name":"TrailRun","page-image":"","image-kw":"","feed":true,"entity":true,"keyword":true,"title":true,"author":"","taxonomy":true,"concept":true,"relation":"","pub-date":"","doc-sentiment":true,"x":246,"y":160,"wires":[["c0d3872.f3f2c78"]]},{"id":"c0d3872.f3f2c78","type":"function","z":"5fa9e76b.a05618","name":"To mark tweets","func":"msg.payload={tweet: msg.payload,score:msg.features};\nreturn msg;\n","outputs":1,"noerr":0,"x":405,"y":217,"wires":[["db13f5f.f24ec08","4a1ed314.b5e12c"]]},{"id":"4181cf8.fbe7e3","type":"http request","z":"5fa9e76b.a05618","name":"News","method":"GET","ret":"obj","url":"https://gateway-a.watsonplatform.net/calls/data/GetNews?apikey=&outputMode=json&start=now-1d&end=now&count=1&q.enriched.url.enrichedTitle.relations.relation=|action.verb.text=acquire,object.entities.entity.type=Company|&return=enriched.url.title","x":105,"y":229,"wires":[["f84ebc6a.07b14"]]},{"id":"53cc794e.ac3388","type":"inject","z":"5fa9e76b.a05618","name":"GetNews","topic":"News","payload":"","payloadType":"string","repeat":"","crontab":"","once":false,"x":75,"y":379,"wires":[["4181cf8.fbe7e3"]]}]

  • Can we see what you have done so far? Are you using code or console commands to achieve what you have described? – halfer Dec 12 '15 at 09:31
  • If the JSON is code to be reviewed, is it worth your [formatting it](http://jsonviewer.stack.hu/) first? It is not very readable in its current state. – halfer Dec 13 '15 at 10:14

1 Answers1

1

First you have to bind an Alchemy service instance to your node-red application.

Then you can develop your application, here is an example using the http and Feature Extract nodes:

enter image description here

Here is the node flow for this basic sample if you want to try:

[{"id":"e191029.f1e6f","type":"function","z":"2fc2a93f.d03d56","name":"","func":"msg.payload = msg.payload.url;\nreturn msg;","outputs":1,"noerr":0,"x":276,"y":202,"wires":[["12082910.edf7d7"]]},{"id":"12082910.edf7d7","type":"alchemy-feature-extract","z":"2fc2a93f.d03d56","name":"","page-image":"","image-kw":"","feed":"","entity":true,"keyword":true,"title":true,"author":true,"taxonomy":true,"concept":true,"relation":true,"pub-date":true,"doc-sentiment":true,"x":484,"y":203,"wires":[["8a3837f.f75c7c8","d164d2af.2e9b3"]]},{"id":"8a3837f.f75c7c8","type":"debug","z":"2fc2a93f.d03d56","name":"Alchemy Debug","active":true,"console":"true","complete":"true","x":736,"y":156,"wires":[]},{"id":"fb988171.04678","type":"http in","z":"2fc2a93f.d03d56","name":"Test Alchemy","url":"/test_alchemy","method":"get","swaggerDoc":"","x":103.5,"y":200,"wires":[["e191029.f1e6f"]]},{"id":"d164d2af.2e9b3","type":"http response","z":"2fc2a93f.d03d56","name":"End Test Alchemy","x":749,"y":253,"wires":[]}]

You can use curl to test it, for example:

curl -G http://yourapp.mybluemix.net/test_alchemy?url=<your url here>

or use your browser as well:

http://yourapp.mybluemix.net/test_alchemy?url=http://myurl_to_test_alchemy

You can see the results in the node-red debug tab or your can see it in application logs:

$ cf logs yourapp --recent
Alex da Silva
  • 4,552
  • 2
  • 17
  • 25
  • Thanks alot for prompt response. I got little success using alchemy key. I am adding my code as answer to it below. But I am not to the mark yet.My task is to get specific tweets about some companies and also news using alchemy news api about those specific companies and then use alchemy feature-extract node to get the text and sentiment of it. Please review my code and help me with the necessary changes. I need it in a format which I can use easily in bigsheets to separate the company name and sentiment of them to make a chart out of it. – Sumit Agarwal Dec 13 '15 at 03:41