Skip to content

Commit aad8b04

Browse files
added examples for alchemy
1 parent ac9026c commit aad8b04

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ APIs and SDKs that use cognitive computing to solve complex problems.
2020
* [Getting the Service Credentials](#getting-the-service-credentials)
2121
* [Alchemy Services](#alchemy-services)
2222
* [Alchemy Language](#alchemy-language)
23+
* [Alchemy Vision](#alchemy-vision)
24+
* [Alchemy Data News](#alchemy-data-news)
2325
* [IBM Watson Services](#ibm-watson-services)
2426
* [Authorization](#authorization)
2527
* [Concept Expansion](#concept-expansion)
@@ -124,6 +126,55 @@ alchemy_language.sentiment(params, function (err, response) {
124126
});
125127
```
126128

129+
### Alchemy Vision
130+
[Alchemy Vision][alchemy_vision] uses deep learning innovations to understand a picture's content and context. It sees complex visual scenes in their entirety —without needing any textual clues— leveraging a holistic approach to understanding the multiple objects and surroundings.
131+
132+
Example: Extract keywords from an image.
133+
134+
```javascript
135+
var watson = require('watson-developer-cloud');
136+
var fs = require('fs');
137+
138+
var alchemy_vision = watson.alchemy_vision({
139+
api_key: '<api_key>'
140+
});
141+
142+
var params = {
143+
image: fs.fs.createReadStream('src/test/resources/obama.jpg')
144+
};
145+
146+
alchemy_vision.getImageKeywords(params, function (err, keywords) {
147+
if (err)
148+
console.log('error:', err);
149+
else
150+
console.log(JSON.stringify(keywords, null, 2));
151+
});
152+
```
153+
154+
### Alchemy Data News
155+
[Alchemy Data News][alchemy_data_news] indexes 250k to 300k English language news and blog articles every day with historical search available for the past 60 days.
156+
Example: Get the volume data from the last 7 days using 12hs of time slice.
157+
158+
```javascript
159+
var watson = require('watson-developer-cloud');
160+
161+
var alchemy_data_news = watson.alchemy_data_news({
162+
api_key: '<api_key>'
163+
});
164+
165+
var params = {
166+
start: 'now-1d',
167+
end: 'now'
168+
};
169+
170+
alchemy_data_news.getNews(params, function (err, news) {
171+
if (err)
172+
console.log('error:', err);
173+
else
174+
console.log(JSON.stringify(news, null, 2));
175+
});
176+
```
177+
127178
## IBM Watson Services
128179
The Watson Developer Cloud offers a variety of services for building cognitive
129180
apps.
@@ -598,6 +649,9 @@ See [CONTRIBUTING](https://github.com/watson-developer-cloud/nodejs-wrapper/blob
598649

599650
[alchemy_language]: http://www.alchemyapi.com/products/alchemylanguage
600651
[sentiment_analysis]: http://www.alchemyapi.com/products/alchemylanguage/sentiment-analysis
652+
[alchemy_vision]: http://www.alchemyapi.com/products/alchemyvision
653+
[alchemy_data_news]: http://www.alchemyapi.com/products/alchemydata-news
654+
601655
[wdc]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/
602656
[bluemix]: https://console.ng.bluemix.net
603657
[npm_link]: https://www.npmjs.com/package/watson-developer-cloud

examples/alchemy_data_news.v1.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
var watson = require('watson-developer-cloud');
4+
5+
var alchemy_data_news = watson.alchemy_data_news({
6+
api_key: '<api_key>'
7+
});
8+
9+
var params = {
10+
start: 'now-1d',
11+
end: 'now'
12+
};
13+
14+
alchemy_data_news.getNews(params, function (err, news) {
15+
if (err)
16+
console.log('error:', err);
17+
else
18+
console.log(JSON.stringify(news, null, 2));
19+
});

examples/alchemy_vision.v1.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
var watson = require('watson-developer-cloud');
4+
var fs = require('fs');
5+
6+
var alchemy_vision = watson.alchemy_vision({
7+
api_key: '<api_key>'
8+
});
9+
10+
var params = {
11+
image: fs.fs.createReadStream('src/test/resources/obama.jpg')
12+
};
13+
14+
alchemy_vision.getImageKeywords(params, function (err, keywords) {
15+
if (err)
16+
console.log('error:', err);
17+
else
18+
console.log(JSON.stringify(keywords, null, 2));
19+
});

services/alchemy_vision/v1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ AlchemyVision.prototype.imageLinks = function(_params, callback ) {
108108
/**
109109
* Tags image with keywords
110110
*/
111-
AlchemyVision.prototype.imageKeywords = function(_params, callback) {
111+
AlchemyVision.prototype.getImageKeywords = function(_params, callback) {
112112
var params = _params || {};
113113
var accepted_formats = Object.keys(endpoints['image_keywords']);
114114
var format = helper.getFormat(params, accepted_formats);

0 commit comments

Comments
 (0)