Skip to content

Commit 04d1775

Browse files
Merge latest changes from dev
2 parents 5bcd126 + ba47a03 commit 04d1775

File tree

13 files changed

+217
-31
lines changed

13 files changed

+217
-31
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ script:
99
after_success:
1010
- npm run coveralls
1111
before_install:
12-
- openssl aes-256-cbc -K $encrypted_cb4d3d070e32_key -iv $encrypted_cb4d3d070e32_iv
12+
- openssl aes-256-cbc -K $encrypted_d4f181ef7c79_key -iv $encrypted_d4f181ef7c79_iv
1313
-in auth.js.enc -out test/resources/auth.js -d

auth.js.enc

1.16 KB
Binary file not shown.

examples/alchemy_data_news.v1.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ var alchemy_data_news = watson.alchemy_data_news({
66
api_key: '<api_key>'
77
});
88

9+
// News about company acquisitions in the past 24 hours:
10+
// More information: http://docs.alchemyapi.com/docs/introduction
911
var params = {
1012
start: 'now-1d',
11-
end: 'now'
13+
end: 'now',
14+
count: 100,
15+
'q.enriched.url.enrichedTitle.relations.relation': '|action.verb.text=acquire,object.entities.entity.type=Company|',
16+
return: 'enriched.url.title'
1217
};
1318

1419
alchemy_data_news.getNews(params, function (err, news) {
1520
if (err)
1621
console.log('error:', err);
1722
else
1823
console.log(JSON.stringify(news, null, 2));
19-
});
24+
});

examples/alchemy_vision.v1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var alchemy_vision = watson.alchemy_vision({
1010
// Image keywords
1111
var params = {
1212
image: fs.createReadStream('resources/car.png')
13+
forceShowAll: 1 // Includes lower confidence tags
1314
};
1415

1516
alchemy_vision.getImageKeywords(params, function (err, keywords) {
@@ -32,6 +33,7 @@ alchemy_vision.getImageKeywords(params, function (err, keywords) {
3233

3334
// Face recognize
3435
var params = {
36+
knowledgeGraph: 1 // Include knowledge graph information in the the results.
3537
url: 'https://upload.wikimedia.org/wikipedia/commons/0/00/Scarlett_Johansson_-_Captain_America_2_press_conference_%28retouched%29_2.jpg'
3638
};
3739

examples/document_conversion.v1-experimental.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ var document_conversion = watson.document_conversion({
1212
// convert a single document
1313
document_conversion.convert({
1414
// (JSON) ANSWER_UNITS, NORMALIZED_HTML, or NORMALIZED_TEXT
15-
file: fs.createReadStream(__dirname + '/resources/document_conversion/sample-docx.docx'),
16-
conversion_target: document_conversion.conversion_target.ANSWER_UNITS
15+
file: fs.createReadStream(__dirname + '/resources/example.html'),
16+
conversion_target: document_conversion.conversion_target.ANSWER_UNITS,
17+
config: {
18+
// split the html file by "h2", "h3" and "h4" tags
19+
html_to_answer_units: {
20+
selectors: [ 'h2','h3', 'h4']
21+
}
22+
}
1723
}, function (err, response) {
1824
if (err) {
1925
console.error(err);
2026
} else {
2127
console.log(JSON.stringify(response, null, 2));
2228
}
23-
});
29+
});

examples/document_conversion_integration.v1-experimental.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Document Conversion Service and upload it to the Retrieve and Rank Service to ma
2121
*/
2222

2323
var watson = require('watson-developer-cloud');
24-
var async = require('async');
24+
var async = require('async');
2525
var fs = require('fs');
2626

2727
/*
@@ -57,17 +57,25 @@ var solrClient = retrieve.createSolrClient({
5757

5858
async.waterfall([
5959

60-
function convert(done){
60+
function convert(done) {
6161
// convert a single document
6262
document_conversion.convert({
6363
// (JSON) ANSWER_UNITS, NORMALIZED_HTML, or NORMALIZED_TEXT
6464
file: fs.createReadStream(__dirname + inputDocument),
65-
conversion_target: document_conversion.conversion_target.ANSWER_UNITS
66-
}, function (err, response) {
65+
conversion_target: document_conversion.conversion_target.ANSWER_UNITS,
66+
config: {
67+
html_to_html: {
68+
specify_content_to_extract: {
69+
enabled: true,
70+
xpaths: ['//h3']
71+
}
72+
}
73+
}
74+
}, function(err, response) {
6775
if (err) {
6876
console.error(err);
6977
} else {
70-
done(null, response);
78+
done(null, response);
7179
}
7280
});
7381
},
@@ -76,13 +84,13 @@ async.waterfall([
7684
console.log('Indexing a document...');
7785
var doc = mapAnswerUnits2SolrDocs(response);
7886
solrClient.add(doc, function(err) {
79-
if(err) {
87+
if (err) {
8088
console.log('Error indexing document: ' + err);
8189
done();
8290
} else {
8391
console.log('Indexed a document.');
8492
solrClient.commit(function(err) {
85-
if(err) {
93+
if (err) {
8694
console.log('Error committing change: ' + err);
8795
} else {
8896
console.log('Successfully committed changes.');
@@ -99,10 +107,12 @@ async.waterfall([
99107
// This query searches for the term 'psychological' in the content_text field.
100108
// For a wildcard query use:
101109
// query.q({ '*' : '*' });
102-
query.q({ 'content_text' : 'psychological' });
110+
query.q({
111+
'content_text': 'psychological'
112+
});
103113

104114
solrClient.search(query, function(err, searchResponse) {
105-
if(err) {
115+
if (err) {
106116
console.log('Error searching for documents: ' + err);
107117
} else {
108118
console.log('Found ' + searchResponse.response.numFound + ' document(s).');
@@ -116,7 +126,7 @@ async.waterfall([
116126
function mapAnswerUnits2SolrDocs(data) {
117127
var answerUnits = data.answer_units;
118128
var solrDocList = [];
119-
answerUnits.forEach(function(value){
129+
answerUnits.forEach(function(value) {
120130
var solrDoc = convertAnswerUnit2SolrDoc(value);
121131
solrDocList.push(solrDoc);
122132
});
@@ -126,9 +136,15 @@ function mapAnswerUnits2SolrDocs(data) {
126136
function convertAnswerUnit2SolrDoc(au) {
127137
var solrDoc;
128138
var auContents = au.content;
129-
auContents.forEach(function(auContent){
130-
if(auContent.media_type === 'text/plain') {
131-
solrDoc = { id : au.id, title: au.title, type: au.type, media_type: auContent.media_type, content_text: auContent.text };
139+
auContents.forEach(function(auContent) {
140+
if (auContent.media_type === 'text/plain') {
141+
solrDoc = {
142+
id: au.id,
143+
title: au.title,
144+
type: au.type,
145+
media_type: auContent.media_type,
146+
content_text: auContent.text
147+
};
132148
}
133149
});
134150
return solrDoc;

services/alchemy_data_news/v1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function errorFormatter(cb) {
3939
function AlchemyDataNews(options) {
4040
// Default URL
4141
var serviceDefaults = {
42-
url: 'https://access.alchemyapi.com/calls'
42+
url: 'https://gateway-a.watsonplatform.net/calls'
4343
};
4444
// Replace default options with user provided
4545
this._options = extend(serviceDefaults, options);
@@ -65,4 +65,4 @@ AlchemyDataNews.prototype.getNews = function(params, callback ) {
6565
return requestFactory(parameters, errorFormatter(callback));
6666
};
6767

68-
module.exports = AlchemyDataNews;
68+
module.exports = AlchemyDataNews;

services/alchemy_language/v1.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
'use strict';
1818

1919
var extend = require('extend');
20+
var util = require('util');
2021
var requestFactory = require('../../lib/requestwrapper');
2122
var endpoints = require('../../lib/alchemy_endpoints.json');
2223
var helper = require('../../lib/helper');
@@ -93,8 +94,12 @@ AlchemyLanguage.prototype.concepts = createRequest('concepts');
9394
* Calculates the sentiment for text, a URL or HTML.
9495
*/
9596
AlchemyLanguage.prototype.sentiment = function(params, callback) {
96-
var service = (params && params.target) ? 'sentiment_targeted' : 'sentiment';
97-
return createRequest(service).call(this, params, callback);
97+
var _params = extend({}, params);
98+
var service = (params.target || params.targets) ? 'sentiment_targeted' : 'sentiment';
99+
if (util.isArray(_params.targets))
100+
_params.targets = _params.targets.join('|');
101+
102+
return createRequest(service).call(this, _params, callback);
98103
};
99104
/**
100105
* Extracts the cleaned text (removes ads, navigation, etc.) for a URL or HTML.

services/concept_insights/v2.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,13 @@ ConceptInsightsGraphs.prototype.getRelationScores = function(params, callback) {
205205
* Retrieves the available corpora
206206
*/
207207
ConceptInsightsCorpora.prototype.listCorpora = function(params, callback) {
208+
var path = '/v2/corpora';
209+
if (params && params.account_id)
210+
path += '/' + params.account_id;
211+
208212
var parameters = {
209213
options: {
210-
url: '/v2/corpora',
214+
url: path,
211215
method: 'GET',
212216
json: true
213217
},

services/dialog/v1.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ Dialog.prototype.updateProfile = function(params, callback) {
6565
url: '/v1/dialogs/{dialog_id}/profile',
6666
method: 'PUT',
6767
json: true,
68-
body: pick(params, ['name_values']),
69-
qs: pick(params, ['client_id']),
68+
body: pick(params, ['name_values','client_id']),
7069
path: params
7170
},
7271
requiredParams: ['dialog_id', 'name_values'],

0 commit comments

Comments
 (0)