From 937f479e2b1eec9b583cb4bec75b023eba282dce Mon Sep 17 00:00:00 2001 From: chughts Date: Mon, 25 Mar 2019 15:26:58 +0000 Subject: [PATCH 1/2] Add Syntax as option to NLU node --- README.md | 5 ++- package.json | 4 +- .../natural_language_understanding/v1.html | 38 ++++++++++++++++++- services/natural_language_understanding/v1.js | 18 ++++++++- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3d853704..c2d3f166 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,11 @@ Node-RED Watson Nodes for IBM Cloud CLA assistant +### New in version 0.7.8 +- MLU Node - Add Syntax to list of selectable features + ### New in version 0.7.7 -- STT Node - Set correct content-type when File-Type reports a mime type of audio/opus for ogg;codec=opus files. +- STT Node - Set correct content-type when File-Type reports a mime type of audio/opus for ogg;codec=opus files. ### New in version 0.7.6 - Bump SDK Dependency to 3.18.2 diff --git a/package.json b/package.json index b0a88de8..2a04c3ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-watson", - "version": "0.7.7", + "version": "0.7.8", "description": "A collection of Node-RED nodes for IBM Watson services", "dependencies": { "async": "^1.5.2", @@ -10,7 +10,7 @@ "temp": "^0.9.0", "qs": "6.x", "image-type": "^2.0.2", - "watson-developer-cloud": "^3.18.2", + "watson-developer-cloud": "^3.18.3", "ibm-cloud-sdk-core": "^0.0.1", "word-count": "^0.2.2", "is-docx": "^0.0.3", diff --git a/services/natural_language_understanding/v1.html b/services/natural_language_understanding/v1.html index 2c05405a..37c52cb0 100644 --- a/services/natural_language_understanding/v1.html +++ b/services/natural_language_understanding/v1.html @@ -179,6 +179,27 @@ id="node-input-maxsemantics" /> +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ @@ -215,11 +236,13 @@
  • Relations, identify Subject-Action-Object relations.
  • Semantic Roles, parse out sentences into subject, action, and object form.
  • +
  • Syntax, Returns information about the tokens and sentences in + the input text.
  • You can limit the text analyzed by setting limit text characters. A value - of 0 applies no limit. + of 0 applies no limit.

    For full details on the feature details, please see the @@ -265,6 +288,9 @@ $('#node-input-semantic-entities').parent().hide(); $('#node-input-semantic-keywords').parent().hide(); $('#node-input-maxsemantics').parent().hide(); + $('#node-input-syntax-sentences').parent().hide(); + $('#node-input-syntax-tokens-lemma').parent().hide(); + $('#node-input-syntax-tokens-pos').parent().hide(); }; nluV1.setVisibility = function(field, visible) { @@ -318,6 +344,12 @@ nluV1.CreateIListener($('#node-input-default-endpoint'), $('#node-input-service-endpoint'), true); + nluV1.CreateIListener($('#node-input-syntax'), + $('#node-input-syntax-sentences' + + ', #node-input-syntax-tokens-lemma' + + ', #node-input-syntax-tokens-pos')); + + } nluV1.checkForPrepare = function () { @@ -368,6 +400,10 @@ 'semantic-keywords': {value: false}, 'maxsemantics' :{value: '50'}, 'limittextcharacters': {value: '0'}, + 'syntax': {value: false}, + 'syntax-sentences': {value: false}, + 'syntax-tokens-lemma': {value: false}, + 'syntax-tokens-pos': {value: false}, 'default-endpoint' :{value: true}, 'service-endpoint' :{value: 'https://gateway.watsonplatform.net/natural-language-understanding/api'} }, diff --git a/services/natural_language_understanding/v1.js b/services/natural_language_understanding/v1.js index e30337e0..e17bafb1 100644 --- a/services/natural_language_understanding/v1.js +++ b/services/natural_language_understanding/v1.js @@ -27,7 +27,8 @@ module.exports = function (RED) { 'keyword': 'keywords', 'metadata': 'metadata', 'relation': 'relations', - 'semantic': 'semantic_roles' + 'semantic': 'semantic_roles', + 'syntax': 'syntax' }; var pkg = require('../../package.json'), @@ -153,6 +154,20 @@ module.exports = function (RED) { } } + function processSyntaxOptions(msg, config, features) { + if (features.syntax) { + features.syntax.sentences = + config['syntax-sentences'] ? config['syntax-sentences'] : false; + if (config['syntax-tokens-lemma'] || config['syntax-tokens-pos']) { + features.syntax.tokens = {}; + features.syntax.tokens.lemma = + config['syntax-tokens-lemma'] ? config['syntax-tokens-lemma'] : false; + features.syntax.tokens.part_of_speech = + config['syntax-tokens-pos'] ? config['syntax-tokens-pos'] : false; + } + } + } + function processRelationsOptions(msg, config, features) { if (features.relations) { if (msg.nlu_options && msg.nlu_options.relations_model) { @@ -195,6 +210,7 @@ module.exports = function (RED) { processRelationsOptions(msg,config, options.features); processKeywordsOptions(config, options.features); processSemanticRolesOptions(config, options.features); + processSyntaxOptions(msg,config, options.features); } return Promise.resolve(); } From f7944554d14f73d2972bf14697b5854bfe126c17 Mon Sep 17 00:00:00 2001 From: chughts Date: Mon, 25 Mar 2019 16:55:36 +0000 Subject: [PATCH 2/2] Add Syntax as option to NLU node --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2d3f166..8786a28b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Node-RED Watson Nodes for IBM Cloud CLA assistant ### New in version 0.7.8 -- MLU Node - Add Syntax to list of selectable features +- NLU Node - Add Syntax to list of selectable features ### New in version 0.7.7 - STT Node - Set correct content-type when File-Type reports a mime type of audio/opus for ogg;codec=opus files.