@@ -100,17 +100,19 @@ module.exports = function (RED) {
100100 //context.set('watson-translate-node', {'one': 'aaa', 'two' : 'bbb'});
101101 } ) ;
102102
103-
104- // The node has received an input as part of a flow, need to determine what the request
105- // is for, and based on that if the required fields have been provided.
103+
104+ // The node has received an input as part of a flow, need to determine
105+ // what the request is for, and based on that if the required fields
106+ //have been provided.
106107 this . on ( 'input' , function ( msg ) {
107108
108- // These are var functions that have been initialised here, so that they are available for the
109- // instance of this node to use. Tried to make these protoypes, but couldn't get them to be
109+ // These are var functions that have been initialised here, so that
110+ // they are available for the instance of this node to use.
111+ // Tried to make these protoypes, but couldn't get them to be
110112 // invokedd. So instead have opted to go for vars.
111113
112- // If a translation is requested, then the model id will have been built by the calling
113- // function based on source, target and domain.
114+ // If a translation is requested, then the model id will have been
115+ // built by the calling function based on source, target and domain.
114116 var doTranslate = function ( msg , model_id ) {
115117 node . status ( {
116118 fill : 'blue' ,
@@ -131,12 +133,13 @@ module.exports = function (RED) {
131133 msg . payload = response . translations [ 0 ] . translation ;
132134 }
133135 node . send ( msg ) ;
134- } ) ;
136+ }
137+ ) ;
135138 } ;
136139
137140 // If training is requested then the glossary will be a file input. We are using temp
138141 // to sync up the fetch of the file input stream, before invoking the train service.
139- var doTrain = function ( msg , model_id ) {
142+ var doTrain = function ( msg , model_id , filetype ) {
140143 node . status ( {
141144 fill : 'blue' ,
142145 shape : 'dot' ,
@@ -151,7 +154,7 @@ module.exports = function (RED) {
151154 var params = { } ;
152155 // only letters and numbers allowed in the submitted file name
153156 params . name = msg . filename . replace ( / [ ^ 0 - 9 a - z ] / gi, '' ) ;
154- params . base_model_id = basemodel ;
157+ params . base_model_id = model_id ;
155158 switch ( filetype ) {
156159 case 'forcedglossary' :
157160 params . forced_glossary = fs . createReadStream ( info . path ) ;
@@ -236,7 +239,7 @@ module.exports = function (RED) {
236239 {
237240 model_id : trainid ,
238241 } ,
239- function ( err , model ) {
242+ function ( err ) {
240243 if ( err ) {
241244 node . status ( {
242245 fill : 'red' ,
@@ -318,7 +321,7 @@ module.exports = function (RED) {
318321 }
319322 var model_id = '' ;
320323 model_id = srclang + '-' + destlang ;
321- if ( domain != " news" ) {
324+ if ( domain !== ' news' ) {
322325 model_id += ( '-' + domain ) ;
323326 }
324327 doTranslate ( msg , model_id ) ;
0 commit comments