Skip to content

Commit 70fbef8

Browse files
committed
2 parents 2a03972 + 98c7e6f commit 70fbef8

File tree

22 files changed

+243
-119
lines changed

22 files changed

+243
-119
lines changed

.jshintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.jshintrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
},
1616

1717
"node" : true,
18-
"es5" : true,
19-
"browser" : true,
18+
"browser" : false,
2019

2120
"boss" : false,
2221
"curly": false,
@@ -26,7 +25,6 @@
2625
"evil": true,
2726
"forin": false,
2827
"immed": true,
29-
"maxlen": 100,
3028
"indent": 2,
3129
"quotmark": "single",
3230
"laxbreak": false,
@@ -43,4 +41,4 @@
4341
"strict": true,
4442
"white": true,
4543
"unused": true
46-
}
44+
}

README.md

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,11 @@ var watson = require('watson-developer-cloud');
191191
var concept_insights = watson.concept_insights({
192192
username: '<username>',
193193
password: '<password>',
194-
version: 'v1'
194+
version: 'v2'
195195
});
196196

197-
/*** Annotate Text ***/
198-
199197
var params = {
200-
user: 'wikipedia',
201-
graph: 'en-20120601',
198+
graph: '/graphs/wikipedia/en20120601',
202199
text: 'IBM Watson won the Jeopardy television show hosted by Alex Trebek'
203200
};
204201

@@ -207,32 +204,9 @@ concept_insights.annotateText(params, function(err, res) {
207204
if (err)
208205
console.log(err);
209206
else {
210-
console.log("\n*** Annotate Text ***\n");
211207
console.log(JSON.stringify(res, null, 2));
212208
}
213209
});
214-
215-
/*** Semantic Search ***/
216-
217-
var payload = {
218-
func: 'semanticSearch',
219-
ids: [
220-
'/graph/wikipedia/en-20120601/Software_development_process',
221-
'/graph/wikipedia/en-20120601/Programming_tool'
222-
],
223-
corpus: 'ibmresearcher',
224-
user: 'public',
225-
limit: 5
226-
};
227-
228-
concept_insights.semanticSearch(payload, function(error, results) {
229-
if (error)
230-
console.log(error);
231-
else {
232-
console.log("\n*** Semantic Search ***\n");
233-
console.log(JSON.stringify(results, null, 2));
234-
}
235-
});
236210
```
237211

238212
### Dialog
@@ -327,7 +301,7 @@ var natural_language_classifier = watson.natural_language_classifier({
327301

328302
natural_language_classifier.classify({
329303
text: 'Is it sunny?',
330-
classifier: '<classifier-id>' },
304+
classifier_id: '<classifier-id>' },
331305
function(err, response) {
332306
if (err)
333307
console.log('error:', err);

examples/concept_insights.v2.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
var watson = require('watson-developer-cloud');
4+
5+
var concept_insights = watson.concept_insights({
6+
username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
7+
password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE',
8+
version: 'v2'
9+
});
10+
11+
var params = {
12+
graph: '/graphs/wikipedia/en20120601',
13+
text: 'IBM Watson won the Jeopardy television show hosted by Alex Trebek'
14+
};
15+
16+
// Retrieve the concepts for input text
17+
concept_insights.annotateText(params, function(err, res) {
18+
if (err)
19+
console.log(err);
20+
else {
21+
console.log('Annotated Text');
22+
console.log(JSON.stringify(res, null, 2));
23+
}
24+
});

examples/natural_language_classifier.v1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ natural_language_classifier.create(params, function(err, response) {
2929
// Using a classifier
3030
natural_language_classifier.classify({
3131
text: 'Is it sunny?',
32-
classifier: '<classifier-id>' }, // from the previous command
32+
classifier_id: '<classifier-id>' }, // from the previous command
3333
function(err, response) {
3434
if (err)
3535
console.log('error:', err);

examples/retrieve_and_rank_lifecycle.v1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async.series([
2121
},
2222

2323
function createCluster(done) {
24-
retrieve.createCluster({}, function getId(err, res) {
24+
retrieve.createCluster({cluster_name: 'example_cluster', cluster_size: '1'}, function getId(err, res) {
2525
if (err) {
2626
return console.log('Error creating Solr cluster: ' + JSON.stringify(err));
2727
}

lib/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
for(var i = 0; i < formats.length; i++) {
6363
if (formats[i] in params)
6464
return formats[i];
65-
};
65+
}
6666
return null;
6767
}
68-
};
68+
};

lib/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function createServiceAPI(serviceName) {
4545
}
4646

4747
// Get credentials from Bluemix
48-
if (options.use_vcap_services != false) {
48+
if (options.use_vcap_services !== false) {
4949
var service = bluemix.serviceStartsWith(serviceName);
5050
options = extend({}, options, service.credentials);
5151
}
@@ -55,7 +55,7 @@ function createServiceAPI(serviceName) {
5555
pass = options.password,
5656
api_key = options.api_key;
5757

58-
if (typeof(options.use_unauthenticated) === 'undefined' || options.use_unauthenticated == false) {
58+
if (!options.use_unauthenticated) {
5959
// Check if 'api_key' or 'username' and 'password' were provided
6060
if (typeof api_key === 'undefined') {
6161
if (typeof user === 'undefined' || typeof pass === 'undefined') {
@@ -83,7 +83,11 @@ function createServiceAPI(serviceName) {
8383
var s = new Service(options);
8484
return Object.freeze(s);
8585
} catch (e) {
86-
throw new Error(util.format('Argument error: %s not found for: %s', version, serviceName));
86+
if (e.code === 'MODULE_NOT_FOUND') {
87+
throw new Error(util.format('Service %s %s not found', serviceName, version));
88+
} else {
89+
throw e;
90+
}
8791
}
8892
};
8993
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "watson-developer-cloud",
3-
"version": "0.9.29",
3+
"version": "0.9.30",
44
"description": "Nodejs Client Wrapper to use the IBM Watson and Services",
55
"main": "./lib/index",
66
"repository": {
@@ -68,6 +68,7 @@
6868
"csv-stringify": "~0.0.8",
6969
"extend": "~3.0.0",
7070
"isstream": "~0.1.2",
71+
"jshint": "^2.8.0",
7172
"object.omit": "~2.0.0",
7273
"object.pick": "~1.1.1",
7374
"request": "~2.61.0",
@@ -78,7 +79,7 @@
7879
"node": ">=0.10"
7980
},
8081
"scripts": {
81-
"test": "mocha --reporter spec --timeout 4000",
82+
"test": "jshint --exclude node_modules/ **/*.js && mocha --reporter spec --timeout 4000",
8283
"prepare": "npm test && npm version patch",
8384
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --reporter spec --timeout 4000",
8485
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"

services/alchemy_language/v1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var requestFactory = require('../../lib/requestwrapper');
2121
var endpoints = require('../../lib/alchemy_endpoints.json');
2222
var helper = require('../../lib/helper');
2323

24-
var errorFormatter = function(cb) {
24+
function errorFormatter(cb) {
2525
return function(err, result, response) {
2626
if (err) {
2727
cb(err, result);

0 commit comments

Comments
 (0)