Skip to content

Commit 2869917

Browse files
authored
Merge pull request #453 from chughts/syntax
NLU Syntax
2 parents 2eab7e0 + f794455 commit 2869917

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ Node-RED Watson Nodes for IBM Cloud
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.7.8
11+
- NLU Node - Add Syntax to list of selectable features
12+
1013
### New in version 0.7.7
11-
- STT Node - Set correct content-type when File-Type reports a mime type of audio/opus for ogg;codec=opus files.
14+
- STT Node - Set correct content-type when File-Type reports a mime type of audio/opus for ogg;codec=opus files.
1215

1316
### New in version 0.7.6
1417
- Bump SDK Dependency to 3.18.2

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-watson",
3-
"version": "0.7.7",
3+
"version": "0.7.8",
44
"description": "A collection of Node-RED nodes for IBM Watson services",
55
"dependencies": {
66
"async": "^1.5.2",
@@ -10,7 +10,7 @@
1010
"temp": "^0.9.0",
1111
"qs": "6.x",
1212
"image-type": "^2.0.2",
13-
"watson-developer-cloud": "^3.18.2",
13+
"watson-developer-cloud": "^3.18.3",
1414
"ibm-cloud-sdk-core": "^0.0.1",
1515
"word-count": "^0.2.2",
1616
"is-docx": "^0.0.3",

services/natural_language_understanding/v1.html

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,27 @@
179179
id="node-input-maxsemantics" />
180180
</div>
181181

182+
<div>
183+
<input style="width: 30px; margin-left: 20px; margin-top: 0;"
184+
type="checkbox" id="node-input-syntax" />
185+
<label style="width: auto;" for="node-input-syntax">Syntax</label>
186+
</div>
187+
<div>
188+
<input style="width: 30px; margin-left: 20px; margin-top: 0;"
189+
type="checkbox" id="node-input-syntax-sentences" />
190+
<label style="width: auto;" for="node-input-syntax-sentences">Syntax Sentences</label>
191+
</div>
192+
<div>
193+
<input style="width: 30px; margin-left: 20px; margin-top: 0;"
194+
type="checkbox" id="node-input-syntax-tokens-lemma" />
195+
<label style="width: auto;" for="node-input-syntax-tokens-lemma">Lemma Tokens</label>
196+
</div>
197+
<div>
198+
<input style="width: 30px; margin-left: 20px; margin-top: 0;"
199+
type="checkbox" id="node-input-syntax-tokens-pos" />
200+
<label style="width: auto;" for="node-input-syntax-tokens-pos">Part of Speech</label>
201+
</div>
202+
182203
</div>
183204
</div>
184205

@@ -215,11 +236,13 @@
215236
<li><b>Relations</b>, identify Subject-Action-Object relations.</li>
216237
<li><b>Semantic Roles</b>, parse out sentences into subject,
217238
action, and object form.</li>
239+
<li><b>Syntax</b>, Returns information about the tokens and sentences in
240+
the input text. </li>
218241

219242
</ul>
220243
<p>
221244
You can limit the text analyzed by setting limit text characters. A value
222-
of 0 applies no limit.
245+
of 0 applies no limit.
223246
</p>
224247
<p>For full details on the feature details,
225248
please see the
@@ -265,6 +288,9 @@
265288
$('#node-input-semantic-entities').parent().hide();
266289
$('#node-input-semantic-keywords').parent().hide();
267290
$('#node-input-maxsemantics').parent().hide();
291+
$('#node-input-syntax-sentences').parent().hide();
292+
$('#node-input-syntax-tokens-lemma').parent().hide();
293+
$('#node-input-syntax-tokens-pos').parent().hide();
268294
};
269295

270296
nluV1.setVisibility = function(field, visible) {
@@ -318,6 +344,12 @@
318344
nluV1.CreateIListener($('#node-input-default-endpoint'),
319345
$('#node-input-service-endpoint'), true);
320346

347+
nluV1.CreateIListener($('#node-input-syntax'),
348+
$('#node-input-syntax-sentences'
349+
+ ', #node-input-syntax-tokens-lemma'
350+
+ ', #node-input-syntax-tokens-pos'));
351+
352+
321353
}
322354

323355
nluV1.checkForPrepare = function () {
@@ -368,6 +400,10 @@
368400
'semantic-keywords': {value: false},
369401
'maxsemantics' :{value: '50'},
370402
'limittextcharacters': {value: '0'},
403+
'syntax': {value: false},
404+
'syntax-sentences': {value: false},
405+
'syntax-tokens-lemma': {value: false},
406+
'syntax-tokens-pos': {value: false},
371407
'default-endpoint' :{value: true},
372408
'service-endpoint' :{value: 'https://gateway.watsonplatform.net/natural-language-understanding/api'}
373409
},

services/natural_language_understanding/v1.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module.exports = function (RED) {
2727
'keyword': 'keywords',
2828
'metadata': 'metadata',
2929
'relation': 'relations',
30-
'semantic': 'semantic_roles'
30+
'semantic': 'semantic_roles',
31+
'syntax': 'syntax'
3132
};
3233

3334
var pkg = require('../../package.json'),
@@ -153,6 +154,20 @@ module.exports = function (RED) {
153154
}
154155
}
155156

157+
function processSyntaxOptions(msg, config, features) {
158+
if (features.syntax) {
159+
features.syntax.sentences =
160+
config['syntax-sentences'] ? config['syntax-sentences'] : false;
161+
if (config['syntax-tokens-lemma'] || config['syntax-tokens-pos']) {
162+
features.syntax.tokens = {};
163+
features.syntax.tokens.lemma =
164+
config['syntax-tokens-lemma'] ? config['syntax-tokens-lemma'] : false;
165+
features.syntax.tokens.part_of_speech =
166+
config['syntax-tokens-pos'] ? config['syntax-tokens-pos'] : false;
167+
}
168+
}
169+
}
170+
156171
function processRelationsOptions(msg, config, features) {
157172
if (features.relations) {
158173
if (msg.nlu_options && msg.nlu_options.relations_model) {
@@ -195,6 +210,7 @@ module.exports = function (RED) {
195210
processRelationsOptions(msg,config, options.features);
196211
processKeywordsOptions(config, options.features);
197212
processSemanticRolesOptions(config, options.features);
213+
processSyntaxOptions(msg,config, options.features);
198214
}
199215
return Promise.resolve();
200216
}

0 commit comments

Comments
 (0)