node-nlp
Version:
Library for NLU (Natural Language Understanding) done in Node.js
2,095 lines (502 loc) • 25.4 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Recognizer</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Recognizer</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Recognizer<span class="signature">(settings)</span><span class="type-signature"></span></h2>
<div class="class-description">Microsoft Bot Framework compatible recognizer for nlp.js.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Recognizer"><span class="type-signature"></span>new Recognizer<span class="signature">(settings)</span><span class="type-signature"></span></h4>
<div class="description">
Constructor of the class.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Settings for the instance.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line30">line 30</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="defaultRouting"><span class="type-signature"></span>defaultRouting<span class="signature">(bot, session, results)</span><span class="type-signature"></span></h4>
<div class="description">
Route to a default route of the bot. First the route is calculated as the
best route based on the results and the dialog stack. If no best route exists
then is routed to the active dialog.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>bot</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Microsoft Bot Framework Universal Bot instance.</td>
</tr>
<tr>
<td class="name"><code>session</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Microsoft bot framework session.</td>
</tr>
<tr>
<td class="name"><code>results</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Results for the routing.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line207">line 207</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getDialogId"><span class="type-signature"></span>getDialogId<span class="signature">(session)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Gets the last developer (not framework) dialogId on the stack.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>session</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Microsoft bot framework session.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line127">line 127</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Last dialog id.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="load"><span class="type-signature"></span>load<span class="signature">(filename)</span><span class="type-signature"></span></h4>
<div class="description">
Loads the model from a file.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Name of the file.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line56">line 56</a>
</li></ul></dd>
</dl>
<h4 class="name" id="loadExcel"><span class="type-signature">(async) </span>loadExcel<span class="signature">(filename)</span><span class="type-signature"></span></h4>
<div class="description">
Loads the NLP manager from an excel.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Name of the file.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line72">line 72</a>
</li></ul></dd>
</dl>
<h4 class="name" id="process"><span class="type-signature">(async) </span>process<span class="signature">(srcContext, locale, Promise)</span><span class="type-signature"></span></h4>
<div class="description">
Process an utterance using the NLP manager. This is done using a given context
as the context object.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>srcContext</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Source context</td>
</tr>
<tr>
<td class="name"><code>locale</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Locale of the utterance.</td>
</tr>
<tr>
<td class="name"><code>Promise</code></td>
<td class="type">
<span class="param-type">Promise.String</span>
</td>
<td class="description last">utterance Utterance to be recognized.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line85">line 85</a>
</li></ul></dd>
</dl>
<h4 class="name" id="processAnswer"><span class="type-signature"></span>processAnswer<span class="signature">(session, answer)</span><span class="type-signature"></span></h4>
<div class="description">
When an answer is received over the threshold, decide what to do with this answer.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>session</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Microsoft bot framework session.</td>
</tr>
<tr>
<td class="name"><code>answer</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Answer given by the NLP.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line224">line 224</a>
</li></ul></dd>
</dl>
<h4 class="name" id="recognize"><span class="type-signature"></span>recognize<span class="signature">(session, cb)</span><span class="type-signature"></span></h4>
<div class="description">
Given a session of a chatbot containing a message, recognize the utterance in the message.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>session</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Chatbot session of the message.</td>
</tr>
<tr>
<td class="name"><code>cb</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback function.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line146">line 146</a>
</li></ul></dd>
</dl>
<h4 class="name" id="recognizeTwice"><span class="type-signature"></span>recognizeTwice<span class="signature">(session, cb)</span><span class="type-signature"></span></h4>
<div class="description">
Given a session of a chatbot containing a message, recognize for second time
the utterance in the message.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>session</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Chatbot session of the message.</td>
</tr>
<tr>
<td class="name"><code>cb</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback function.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line179">line 179</a>
</li></ul></dd>
</dl>
<h4 class="name" id="recognizeUtterance"><span class="type-signature">(async) </span>recognizeUtterance<span class="signature">(utterance, model, cb)</span><span class="type-signature"></span></h4>
<div class="description">
Given an utterance and the locale, returns the recognition of the utterance.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>utterance</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Utterance to be recognized.</td>
</tr>
<tr>
<td class="name"><code>model</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Model of the utterance.</td>
</tr>
<tr>
<td class="name"><code>cb</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback Function.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line112">line 112</a>
</li></ul></dd>
</dl>
<h4 class="name" id="save"><span class="type-signature"></span>save<span class="signature">(filename)</span><span class="type-signature"></span></h4>
<div class="description">
Saves the model into a file.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Name of the file.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line64">line 64</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setBot"><span class="type-signature"></span>setBot<span class="signature">(bot, activateRouting, routingThreshold)</span><span class="type-signature"></span></h4>
<div class="description">
Sets the recognizer to a Microsoft bot framework universal bot instance.
Also, the default bot routing can be overrided and replaced by the
recognizer routing.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>bot</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="default">
</td>
<td class="description last">Microsoft Bot Framework Universal Bot instance.</td>
</tr>
<tr>
<td class="name"><code>activateRouting</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="default">
false
</td>
<td class="description last">True if default routing should be overrided.</td>
</tr>
<tr>
<td class="name"><code>routingThreshold</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="default">
0.7
</td>
<td class="description last">Threshold for the score of the intent.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line239">line 239</a>
</li></ul></dd>
</dl>
<h4 class="name" id="train"><span class="type-signature">(async) </span>train<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Train the NLP manager.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="recognizer_recognizer.js.html">recognizer/recognizer.js</a>, <a href="recognizer_recognizer.js.html#line48">line 48</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BinaryNeuralNetworkClassifier.html">BinaryNeuralNetworkClassifier</a></li><li><a href="Classifier.html">Classifier</a></li><li><a href="ConversationContext.html">ConversationContext</a></li><li><a href="DutchStemmer.html">DutchStemmer</a></li><li><a href="EnglishStemmer.html">EnglishStemmer</a></li><li><a href="EnumNamedEntity.html">EnumNamedEntity</a></li><li><a href="Evaluator.html">Evaluator</a></li><li><a href="HungarianStemmer.html">HungarianStemmer</a></li><li><a href="ItalianStemmer.html">ItalianStemmer</a></li><li><a href="Language.html">Language</a></li><li><a href="LogisticRegressionClassifier.html">LogisticRegressionClassifier</a></li><li><a href="Matrix.html">Matrix</a></li><li><a href="MemoryConversationContext.html">MemoryConversationContext</a></li><li><a href="NamedEntity.html">NamedEntity</a></li><li><a href="NerManager.html">NerManager</a></li><li><a href="NlgManager.html">NlgManager</a></li><li><a href="NlpClassifier.html">NlpClassifier</a></li><li><a href="NlpManager.html">NlpManager</a></li><li><a href="NorwegianStemmer.html">NorwegianStemmer</a></li><li><a href="PortugueseStemmer.html">PortugueseStemmer</a></li><li><a href="Recognizer.html">Recognizer</a></li><li><a href="RegexNamedEntity.html">RegexNamedEntity</a></li><li><a href="RomanianStemmer.html">RomanianStemmer</a></li><li><a href="RussianStemmer.html">RussianStemmer</a></li><li><a href="SentimentAnalyzer.html">SentimentAnalyzer</a></li><li><a href="SentimentManager.html">SentimentManager</a></li><li><a href="SimilarSearch.html">SimilarSearch</a></li><li><a href="SlotManager.html">SlotManager</a></li><li><a href="StemmerJa.html">StemmerJa</a></li><li><a href="SwedishStemmer.html">SwedishStemmer</a></li><li><a href="Tokenizer.html">Tokenizer</a></li><li><a href="TrimNamedEntity.html">TrimNamedEntity</a></li><li><a href="TurkishStemmer.html">TurkishStemmer</a></li><li><a href="Vector.html">Vector</a></li><li><a href="XTable.html">XTable</a></li></ul><h3>Global</h3><ul><li><a href="global.html#endsinArr">endsinArr</a></li><li><a href="global.html#prelude">prelude</a></li><li><a href="global.html#regions">regions</a></li><li><a href="global.html#stem">stem</a></li><li><a href="global.html#stopwords">stopwords</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 13 2018 19:14:51 GMT+0200 (CEST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>