Skip to content

Commit

Permalink
Merge pull request #211 from chughts/torfixes
Browse files Browse the repository at this point in the history
File Inject related Translator fix
  • Loading branch information
chughts committed Oct 16, 2016
2 parents ac63acf + 8137e4b commit 5baef75
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Node-RED Watson Nodes for IBM Bluemix

<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>

### New in version 0.4.23
- Fix to Language Translator Train Node to allow it work with File Inject

### New in version 0.4.22
- Added new Date Extraction Node
- Visual Recognition Node, now defaults detection setting and language on initial initialisation.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-node-watson",
"version": "0.4.22",
"version": "0.4.23",
"description": "A collection of Node-RED nodes for IBM Watson services",
"dependencies": {
"alchemy-api": "^1.3.0",
Expand Down
10 changes: 9 additions & 1 deletion services/language_translator/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ module.exports = function (RED) {

// If training is requested then the glossary will be a file input. We are using temp
// to sync up the fetch of the file input stream, before invoking the train service.
// If the file comes from a file-inject then the file will not have a filename assoicated
// with it. In this case a temporary filename is given to the file. The file name submitted
// to the service cannot have a '.' else it will throw a 400 error.
var doTrain = function(msg, model_id, filetype){
node.status({
fill: 'blue',
Expand All @@ -189,8 +192,13 @@ module.exports = function (RED) {
if (!err) {
fs.write(info.fd, msg.payload);
var params = {};

// only letters and numbers allowed in the submitted file name
params.name = msg.filename.replace(/[^0-9a-z]/gi, '');
// Default the name to a string representing now
params.name = (new Date()).toString().replace(/[^0-9a-z]/gi, '');
if (msg.filename) {
params.name = msg.filename.replace(/[^0-9a-z]/gi, '');
}
params.base_model_id = model_id;
switch (filetype) {
case 'forcedglossary':
Expand Down

0 comments on commit 5baef75

Please sign in to comment.