UNPKG

bravey

Version:

A simple JavaScript NLP-like library to help you creating your own bot.

1,472 lines (417 loc) 20.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Fuzzy</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: Fuzzy</h1> <section> <header> <h2> <span class="ancestors"><a href="Bravey.html">Bravey</a><a href="Bravey.Nlp.html">.Nlp</a>.</span>Fuzzy</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="Fuzzy"><span class="type-signature"></span>new Fuzzy<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> A version of the Natural Language Processing core. Doesn't follow entity order but tries to guess names by samples. Less precise but easier hits. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line5">line 5</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="addDocument"><span class="type-signature"></span>addDocument<span class="signature">(text, intent)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Add a new document. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>text</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The document content.</td> </tr> <tr> <td class="name"><code>intent</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The related intent.</td> </tr> <tr> <td class="name"><code>guess.fromFullSentence</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last">Indicates that the document is a full untagged sentence. (i.e. "Please call the 333-123456")</td> </tr> <tr> <td class="name"><code>guess.fromTaggedSentence</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last">Indicates that the document is tagged with braces. (i.e "Please call the {phone_number}")</td> </tr> <tr> <td class="name"><code>guess.expandIntent</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last">Extends or creates a new intent if exceeded entities are found. New entities id will be autogenerated and progressive.</td> </tr> <tr> <td class="name"><code>guess.withNames</code></td> <td class="type"> <span class="param-type">Array.&lt;string></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> [] </td> <td class="description last">Uses the given names for auto-extending intents. Positions in array are matched with positions of entity into the specified sentence.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line307">line 307</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True when found. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="addEntity"><span class="type-signature"></span>addEntity<span class="signature">(entity)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Adds an entity recognizer. </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>entity</code></td> <td class="type"> <span class="param-type">EntityRecognizer</span> </td> <td class="description last">The entity recognizer to be addded.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line262">line 262</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True when successful. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="addIntent"><span class="type-signature"></span>addIntent<span class="signature">(intentName, entities)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Adds an intent. </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>intentName</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The name of the new intent.</td> </tr> <tr> <td class="name"><code>entities</code></td> <td class="type"> <span class="param-type">Array.&lt;<a href="global.html#IntentEntity">IntentEntity</a>></span> </td> <td class="description last">The produced entities.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line243">line 243</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True when successful. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="getConfidence"><span class="type-signature"></span>getConfidence<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4> <div class="description"> Returns the confidence ratio. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line293">line 293</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The confidence ratio. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> <h4 class="name" id="hasEntity"><span class="type-signature"></span>hasEntity<span class="signature">(entityName)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Check if an entity with a given name exists. </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>entityName</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The entity name.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line277">line 277</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True when found. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="setConfidence"><span class="type-signature"></span>setConfidence<span class="signature">(ratio)</span><span class="type-signature"></span></h4> <div class="description"> Set confidence ratio, from 0.5 to 1. The higher the more strict. </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>ratio</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">The confidence ratio to be set.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line285">line 285</a> </li></ul></dd> </dl> <h4 class="name" id="test"><span class="type-signature"></span>test<span class="signature">(text, method<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="global.html#NlpResult">NlpResult</a>|false}</span></h4> <div class="description"> Check if a given sentence matches an intent and extracts its entities. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>text</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The sentence to be processed.</td> </tr> <tr> <td class="name"><code>method</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> "default" </td> <td class="description last">The extraction method. "anyEntity" extracts all found entities and guess intent, regardless the intents structure.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="nlp_Fuzzy.js.html">nlp/Fuzzy.js</a>, <a href="nlp_Fuzzy.js.html#line354">line 354</a> </li></ul></dd> </dl> <h5>Returns:</h5> <ul> <li> <div class="param-desc"> When an intent is found. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="global.html#NlpResult">NlpResult</a></span> </dd> </dl> </li> <li> <div class="param-desc"> When the sentence doesn't match any intent. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">false</span> </dd> </dl> </li> </ul> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bravey.ApiAiAdapter.html">ApiAiAdapter</a></li><li><a href="Bravey.ContextManager.html">ContextManager</a></li><li><a href="Bravey.DocumentClassifier.html">DocumentClassifier</a></li><li><a href="Bravey.EMailEntityRecognizer.html">EMailEntityRecognizer</a></li><li><a href="Bravey.Filter.BasicFilter.html">BasicFilter</a></li><li><a href="Bravey.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.EN.DateEntityRecognizer.html">DateEntityRecognizer</a></li><li><a href="Bravey.Language.EN.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.EN.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.Language.EN.Stemmer.html">Stemmer</a></li><li><a href="Bravey.Language.EN.TimeEntityRecognizer.html">TimeEntityRecognizer</a></li><li><a href="Bravey.Language.EN.TimePeriodEntityRecognizer.html">TimePeriodEntityRecognizer</a></li><li><a href="Bravey.Language.IT.DateEntityRecognizer.html">DateEntityRecognizer</a></li><li><a href="Bravey.Language.IT.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.IT.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.Language.IT.Stemmer.html">Stemmer</a></li><li><a href="Bravey.Language.IT.TimeEntityRecognizer.html">TimeEntityRecognizer</a></li><li><a href="Bravey.Language.IT.TimePeriodEntityRecognizer.html">TimePeriodEntityRecognizer</a></li><li><a href="Bravey.Language.PT.DateEntityRecognizer.html">DateEntityRecognizer</a></li><li><a href="Bravey.Language.PT.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.PT.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.Language.PT.Stemmer.html">Stemmer</a></li><li><a href="Bravey.Language.PT.TimeEntityRecognizer.html">TimeEntityRecognizer</a></li><li><a href="Bravey.Language.PT.TimePeriodEntityRecognizer.html">TimePeriodEntityRecognizer</a></li><li><a href="Bravey.Nlp.Fuzzy.html">Fuzzy</a></li><li><a href="Bravey.Nlp.Sequential.html">Sequential</a></li><li><a href="Bravey.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.RegexEntityRecognizer.html">RegexEntityRecognizer</a></li><li><a href="Bravey.SessionManager.InMemorySessionManager.html">InMemorySessionManager</a></li><li><a href="Bravey.StringEntityRecognizer.html">StringEntityRecognizer</a></li><li><a href="Bravey.Text.RegexMap.html">RegexMap</a></li></ul><h3>Namespaces</h3><ul><li><a href="Bravey.html">Bravey</a></li><li><a href="Bravey.Data.html">Data</a></li><li><a href="Bravey.Date.html">Date</a></li><li><a href="Bravey.File.html">File</a></li><li><a href="Bravey.Filter.html">Filter</a></li><li><a href="Bravey.Language.html">Language</a></li><li><a href="Bravey.Language.EN.html">EN</a></li><li><a href="Bravey.Language.IT.html">IT</a></li><li><a href="Bravey.Language.PT.html">PT</a></li><li><a href="Bravey.Nlp.html">Nlp</a></li><li><a href="Bravey.SessionManager.html">SessionManager</a></li><li><a href="Bravey.Text.html">Text</a></li></ul><h3><a href="global.html">Global</a></h3> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>