Skip to content

Commit f54dbd9

Browse files
authored
Merge pull request #220 from chughts/docfix
Fix to Document Conversion
2 parents d985ea0 + 2f633a6 commit f54dbd9

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Node-RED Watson Nodes for IBM Bluemix
77

88
<a href="https://cla-assistant.io/watson-developer-cloud/node-red-node-watson"><img src="https://cla-assistant.io/readme/badge/watson-developer-cloud/node-red-node-watson" alt="CLA assistant" /></a>
99

10+
### New in version 0.4.29
11+
- Fix to Document Conversion Node to preserve full msg object
12+
- Fix to Language Translator Node train mode documentation
13+
1014
### New in version 0.4.28
1115
- New V1 Experimental Discovery Node
1216

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-watson",
3-
"version": "0.4.28",
3+
"version": "0.4.29",
44
"description": "A collection of Node-RED nodes for IBM Watson services",
55
"dependencies": {
66
"alchemy-api": "^1.3.0",

services/document_conversion/v1.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,21 @@ module.exports = function(RED) {
8080
if (err) {
8181
node.error(err);
8282
} else {
83-
node.send({
84-
'payload': response
85-
});
83+
msg.payload = response;
84+
node.send(msg);
8685
}
8786
});
8887
};
8988

89+
this.verifyCredentials = function(msg) {
90+
if (node && node.username && node.password) {
91+
return true;
92+
}
93+
node.status({fill:'red', shape:'ring', text:'missing credentials'});
94+
node.error('Missing Watson Document Conversion API service credentials', msg);
95+
return false;
96+
};
97+
9098
this.doCall = function(msg) {
9199
temp.open({
92100
//suffix: '.docx'
@@ -132,7 +140,9 @@ module.exports = function(RED) {
132140
};
133141

134142
this.on('input', function(msg) {
135-
this.doCall(msg);
143+
if (this.verifyCredentials(msg)) {
144+
this.doCall(msg);
145+
}
136146
});
137147
}
138148
RED.nodes.registerType('convert', ConvertNode);

services/language_translator/v2.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,14 @@
146146
<p></p>
147147
<p><b>Training Mode</b>.</p>
148148
<p>This mode enables you to add your own customized model to the Watson Language Translator service. </p>
149-
<p>In the Dropbox node, you must specify one ore more of the following file options to customize the training:</p>
149+
<p>In <code>msg.payload</code>, (this can be through box, dropbox or a file-inject node.
150+
you must specify one of the following file options to customize the training:</p>
150151
<p>forced_glossary - A UTF-8 encoded TMX file that contains pairs of matching terms in the source and target language that are seen as absolute by the system. This file completely overwrites the original domain data.</p>
151152
<p>parallel_corpus - A UTF-8 encoded TMX file that contains matching phrases in the source and target language that serve as examples for Watson. Parallel corpora differ from glossaries because they do not overwrite the original domain data.</p>
152153
<p>monolingual_corpus - A UTF-8 encoded plain text file that contains a body of text in the target language that is related to what you are translating. A monolingual corpus helps improve literal translations to be more fluent and human.</p>
153154
<p>The Language Translator Node will return the ID of the created customized model.</p>
155+
<p<b>Note:</b>As the input file is expected on msg.payload, only one file can be specified. This is
156+
an enforced restriction by this Node. The service API allows more than one file to be specified.</p>
154157
<p></p>
155158
<p><b>Get Status Mode</b>.</p>
156159
<p>This mode allows you to get the status of a model sent to training by providing its ID.</p>
@@ -511,7 +514,7 @@
511514

512515
// Flush out the List before repopulating it.
513516
$('select#node-input-srclang').empty();
514-
517+
515518
input_lang_unique.forEach(function(lang){
516519
var selectedText = '';
517520
if (tor.srclang_selected === lang) {

services/language_translator_identify/v2.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</script>
3636

3737
<script type="text/x-red" data-help-name="watson-language-translator-identify">
38-
<p>Packaged in with release 0.4.26 of node-red-node-watson</p>
38+
<p>Packaged in with release 0.4.29 of node-red-node-watson</p>
3939
<p>The Watson Language Translator service can be used to identify languages used in a text input. <p>
4040
<p>Node input : </p>
4141
<ul>

0 commit comments

Comments
 (0)