node-nlp
Version:
Library for NLU (Natural Language Understanding) done in Node.js
1,290 lines (350 loc) • 17.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: SimilarSearch</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: SimilarSearch</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>SimilarSearch<span class="signature">()</span><span class="type-signature"></span></h2>
<div class="class-description">Class for checking similarity between strings, or search the more similar
substring inside an string.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="SimilarSearch"><span class="type-signature"></span>new SimilarSearch<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Constructor of the class. Does the basic initializations.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line28">line 28</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="getBestSubstring"><span class="type-signature"></span>getBestSubstring<span class="signature">(str1, str2, words1)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Given two strings, search best occurence of the second inside the first,
that is, the consecutive words of the first string that have less
levenshtein distance with the second one.
</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>str1</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">First string.</td>
</tr>
<tr>
<td class="name"><code>str2</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Second string.</td>
</tr>
<tr>
<td class="name"><code>words1</code></td>
<td class="type">
<span class="param-type">Array.<Object></span>
</td>
<td class="description last">Array of positions of the words of the first string.
If not provided this will be built.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line178">line 178</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Best occurence, expressed as the index of the first character,
index of the last character, levenshtein distance and accuracy.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="getBestSubstringList"><span class="type-signature"></span>getBestSubstringList<span class="signature">(str1, str2, words1)</span><span class="type-signature"> → {Array.<Object>}</span></h4>
<div class="description">
Given two strings, search all the occurences of the second inside the first,
where the accuracy is at least as good as the threshold.
</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>str1</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">First string.</td>
</tr>
<tr>
<td class="name"><code>str2</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Second string.</td>
</tr>
<tr>
<td class="name"><code>words1</code></td>
<td class="type">
<span class="param-type">Array.<Object></span>
</td>
<td class="description last">Array of positions of the words of the first string.
If not provided this will be built.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line228">line 228</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
List of occurences.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Object></span>
</dd>
</dl>
<h4 class="name" id="getEdgesFromEntities"><span class="type-signature"></span>getEdgesFromEntities<span class="signature">(str, entities, locale, whitelist)</span><span class="type-signature"></span></h4>
<div class="description">
Given an utterance and an array of entities with options, search the
best option for each entity and return the results.
</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>str</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Utterance to retrieve entities.</td>
</tr>
<tr>
<td class="name"><code>entities</code></td>
<td class="type">
<span class="param-type">Array.<Object></span>
</td>
<td class="description last">Entities Array.</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 for the search.</td>
</tr>
<tr>
<td class="name"><code>whitelist</code></td>
<td class="type">
<span class="param-type">Array.<String></span>
</td>
<td class="description last">Whitelist of entity names for the search.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line359">line 359</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getSimilarity"><span class="type-signature"></span>getSimilarity<span class="signature">(str1, str2)</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Calculates the levenshtein distance between two strings.
</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>str1</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">First String.</td>
</tr>
<tr>
<td class="name"><code>str2</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Second String.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line54">line 54</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Levenshtein distance.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="getWordPositions"><span class="type-signature"></span>getWordPositions<span class="signature">(str)</span><span class="type-signature"> → {Array.<Object>}</span></h4>
<div class="description">
Given an string, iterates over it and return the start position, end position
and length of each of the words, without tokenizing the string.
</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>str</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">String to be processed.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line135">line 135</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array of positions of the words, with the start index,
end index, and length.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Object></span>
</dd>
</dl>
<h4 class="name" id="isAlphanumeric"><span class="type-signature"></span>isAlphanumeric<span class="signature">(c)</span><span class="type-signature"> → {Boolean}</span></h4>
<div class="description">
Indicates if a character is alphanumeric.
</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>c</code></td>
<td class="type">
<span class="param-type">Character</span>
</td>
<td class="description last">Character.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util_similar-search.js.html">util/similar-search.js</a>, <a href="util_similar-search.js.html#line124">line 124</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if the character is alphanumeric, false otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</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>