Skip to content

Commit 5ee1cc1

Browse files
Merge pull request #93 from watson-developer-cloud/document-conversion
Document conversion
2 parents 02fd877 + ec435d6 commit 5ee1cc1

File tree

8 files changed

+572
-8
lines changed

8 files changed

+572
-8
lines changed

README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ APIs and SDKs that use cognitive computing to solve complex problems.
2525
* [Concept Expansion](#concept-expansion)
2626
* [Concept Insights](#concept-insights)
2727
* [Dialog](#dialog)
28+
* [Document Conversion](#document-conversion)
2829
* [Language Translation](#language-translation)
2930
* [Message Resonance](#message-resonance)
3031
* [Natural Language Classifier](#natural-language-classifier)
@@ -221,12 +222,37 @@ var dialog = watson.dialog({
221222
version: 'v1'
222223
});
223224

224-
225225
dialog.getDialogs({}, function (err, dialogs) {
226-
if (err)
227-
console.log('error:', err);
228-
else
229-
console.log(JSON.stringify(dialogs, null, 2));
226+
if (err)
227+
console.log('error:', err);
228+
else
229+
console.log(JSON.stringify(dialogs, null, 2));
230+
});
231+
```
232+
233+
### Document Conversion
234+
235+
```javascript
236+
var watson = require('watson-developer-cloud');
237+
var fs = require('fs');
238+
239+
var document_conversion = watson.document_conversion({
240+
username: '<username>',
241+
password: '<password>',
242+
version: 'v1-experimental'
243+
});
244+
245+
// convert a single document
246+
document_conversion.convert({
247+
// (JSON) ANSWER_UNITS, NORMALIZED_HTML, or NORMALIZED_TEXT
248+
file: fs.createReadStream('sample-docx.docx'),
249+
conversion_target: document_conversion.conversion_target.ANSWER_UNITS
250+
}, function (err, response) {
251+
if (err) {
252+
console.error(err);
253+
} else {
254+
console.log(JSON.stringify(response, null, 2));
255+
}
230256
});
231257
```
232258

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
var watson = require('watson-developer-cloud');
4+
var fs = require('fs');
5+
6+
var document_conversion = watson.document_conversion({
7+
username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
8+
password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE',
9+
version: 'v1-experimental'
10+
});
11+
12+
// convert a single document
13+
document_conversion.convert({
14+
// (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
17+
}, function (err, response) {
18+
if (err) {
19+
console.error(err);
20+
} else {
21+
console.log(JSON.stringify(response, null, 2));
22+
}
23+
});
17.3 KB
Binary file not shown.

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ var watson = {};
114114
'tone_analyzer',
115115
'dialog',
116116
'retrieve_and_rank',
117+
'document_conversion',
118+
117119
// deprecated
118120
'search',
119121
'language_identification',

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"concept insights",
2929
"tradeoff analytics",
3030
"tone analyzer",
31+
"retrieve and rank",
3132
"natural language classifier",
3233
"dialog",
3334
"tone_analyzer",
@@ -61,6 +62,7 @@
6162
"coveralls": "~2.11.2",
6263
"istanbul": "~0.3.15",
6364
"nock": "~2.10.0",
65+
"jshint": "~2.8.0",
6466
"qs": "~4.0.0"
6567
},
6668
"dependencies": {
@@ -69,7 +71,6 @@
6971
"csv-stringify": "~0.0.8",
7072
"extend": "~3.0.0",
7173
"isstream": "~0.1.2",
72-
"jshint": "^2.8.0",
7374
"object.omit": "~2.0.0",
7475
"object.pick": "~1.1.1",
7576
"request": "~2.61.0",

services/concept_expansion/v1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function decodeConcept(encoded_concept) {
6060
return concept_decode[word];
6161
})
6262
};
63-
};
63+
}
6464

6565
function responseFormatter(cb) {
6666
return function(err, result) {
@@ -72,7 +72,7 @@ function responseFormatter(cb) {
7272
cb(null, result);
7373
}
7474
};
75-
};
75+
}
7676

7777
function ConceptExpansion(options) {
7878
var serviceDefaults = {

0 commit comments

Comments
 (0)