Skip to content

Listen Lexicon node

Guidone edited this page Jan 30, 2020 · 3 revisions

This node is deprecated, use the NLP.js nodes

The Listen Lexicon node allows to create custom category of terms for the Listen node in order to expand the pattern matching.

In order to use it chain one or more Listen Lexicon node before a Listen node.

Lexicon

For example in order to detect a car entity in a sentence, define a lexicon Car with the following terms

lamborghini
ferrari
fiat
audi
bmw
toyota
chrisler

At this point the listen node it's able to use rules like

1. "drive[verb]" "[car]->my_car"
2. "my" "car[noun]" "is" "[car]->my_car" 

And this will match sentences like

"my car is a Lamborghini"
// MATCH, msg.chat('my_car') = "lamborghini"
"my car is a toyota"
// MATCH, msg.chat('my_car') = "toyota"
"I am driving a Fiat"
// MATCH, msg.chat('my_car') = "fiat"
"I am driving a Chevrolet"
// NO MATCH

Please note that the name of the lexicon is case sensitive.

It's also possible to create a lexicon for the Listen node programmatically, in that case the the Listen Lexicon node is not necessary, in a upstream Function node connected to a Listen node

msg.payload.lexicon = {
  'lamborghini': 'car',
  'ferrari': 'car',
  'fiat': 'car',
  'audi': 'car',
  'bmw': 'car',
  'toyota': 'car',
  'chrisler': 'car'
};
return msg;
Clone this wiki locally