File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
services/language_translator Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ 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.23
11+ - Fix to Language Translator Train Node to allow it work with File Inject
12+
1013### New in version 0.4.22
1114- Added new Date Extraction Node
1215- Visual Recognition Node, now defaults detection setting and language on initial initialisation.
Original file line number Diff line number Diff line change 11{
22 "name" : " node-red-node-watson" ,
3- "version" : " 0.4.22 " ,
3+ "version" : " 0.4.23 " ,
44 "description" : " A collection of Node-RED nodes for IBM Watson services" ,
55 "dependencies" : {
66 "alchemy-api" : " ^1.3.0" ,
Original file line number Diff line number Diff line change @@ -176,6 +176,9 @@ module.exports = function (RED) {
176176
177177 // If training is requested then the glossary will be a file input. We are using temp
178178 // to sync up the fetch of the file input stream, before invoking the train service.
179+ // If the file comes from a file-inject then the file will not have a filename assoicated
180+ // with it. In this case a temporary filename is given to the file. The file name submitted
181+ // to the service cannot have a '.' else it will throw a 400 error.
179182 var doTrain = function ( msg , model_id , filetype ) {
180183 node . status ( {
181184 fill : 'blue' ,
@@ -189,8 +192,13 @@ module.exports = function (RED) {
189192 if ( ! err ) {
190193 fs . write ( info . fd , msg . payload ) ;
191194 var params = { } ;
195+
192196 // only letters and numbers allowed in the submitted file name
193- params . name = msg . filename . replace ( / [ ^ 0 - 9 a - z ] / gi, '' ) ;
197+ // Default the name to a string representing now
198+ params . name = ( new Date ( ) ) . toString ( ) . replace ( / [ ^ 0 - 9 a - z ] / gi, '' ) ;
199+ if ( msg . filename ) {
200+ params . name = msg . filename . replace ( / [ ^ 0 - 9 a - z ] / gi, '' ) ;
201+ }
194202 params . base_model_id = model_id ;
195203 switch ( filetype ) {
196204 case 'forcedglossary' :
You can’t perform that action at this time.
0 commit comments