NLP functions allow you to process messages, extract intentions and entities from them, and manage text processing.
nlp.parseParses natural language text.
Signature: nlp.parse(message string|UserMessage) Sentence
Arguments: message — natural language text or UserMessage object.
Return value: Sentence object containing information about all intents and entities in the source message.
The function extracts only number and date/time entities from the text. To work with intents and other entities, use the
nlu.parsefunction.
Example of use:
$sentence = nlp.parse(queue.first()) // parse the first user message
nlp.joinJoins two natural language texts into one and then parses it.
Signature: nlp.join(message1 string|UserMessage, message2 string|UserMessage) Sentence
Arguments:
message1 — natural language text or UserMessage object.message2 — natural language text or UserMessage object.Return value: Sentence object containing information about all intents and entities in the merged message.
Example of use:
$sentence = nlp.join(queue.lastNth(2), queue.lastNth(1)) // combine the penultimate and last user messages and then parse it
nlp.setPerceptionAllows you to set a user message for processing in other nodes (blocks) of the bot's scheme.
Signature: nlp.setPerception($sentence Sentence)
Arguments: sentence — a Sentence object containing information about the intentions and entities of the message.
Return value: None.
It should be noted that setPerception sets the text only for processing in the next block. If no processing follows, the perception value is cleared. If there are other blocks between the use of the setPerception function and the text processing, the processing will not occur.
Example of use:
$sentence = nlp.join(queue.lastNth(2), queue.lastNth(1)) // combine the penultimate and last user messages and then parse it
nlp.setPerception($sentence) // Now the rest of the nodes in the scheme will work with the $sentence message