node-nlp
Version:
Library for NLU (Natural Language Understanding) done in Node.js
2,229 lines (585 loc) • 25.8 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Vector</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: Vector</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Vector<span class="signature">(elements, useClone)</span><span class="type-signature"></span></h2>
<div class="class-description">Class representing a Vector and some of the possible operations.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Vector"><span class="type-signature"></span>new Vector<span class="signature">(elements, useClone)</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>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>elements</code></td>
<td class="type">
<span class="param-type">Array.<Number></span>
|
<span class="param-type"><a href="Vector.html">Vector</a></span>
</td>
<td class="default">
</td>
<td class="description last">Elements for initializing the vector.</td>
</tr>
<tr>
<td class="name"><code>useClone</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="default">
true
</td>
<td class="description last">If true, the input array is cloned. If false, it uses
the elements input directly by reference.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line27">line 27</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".createArray"><span class="type-signature">(static) </span>createArray<span class="signature">(numElements, value)</span><span class="type-signature"> → {Array.<Number>}</span></h4>
<div class="description">
Creates a new array, where we can say the number of elements, and also the
value used for initializing each cell of the array.
</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>numElements</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Number of elements.</td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Initialization value.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line51">line 51</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array initialized with the given value at each cell.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Number></span>
</dd>
</dl>
<h4 class="name" id=".one"><span class="type-signature">(static) </span>one<span class="signature">(numElements)</span><span class="type-signature"> → {Array.<Number>}</span></h4>
<div class="description">
Creates a new array where each element value is 1.
</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>numElements</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Number of elements.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line64">line 64</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array where each cell is 1.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Number></span>
</dd>
</dl>
<h4 class="name" id=".zero"><span class="type-signature">(static) </span>zero<span class="signature">(numElements)</span><span class="type-signature"> → {Array.<Number>}</span></h4>
<div class="description">
Creates a new array where each element value is 0.
</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>numElements</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Number of elements.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line73">line 73</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array where each cell is 0.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Number></span>
</dd>
</dl>
<h4 class="name" id="augment"><span class="type-signature"></span>augment<span class="signature">(values)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Return a new array that is the concatenation of both.
</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>values</code></td>
<td class="type">
<span class="param-type"><a href="Vector.html">Vector</a></span>
|
<span class="param-type">Array.<Number></span>
</td>
<td class="description last">Vector or array to be added.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line187">line 187</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Vector that is concat of this with values.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="chomp"><span class="type-signature"></span>chomp<span class="signature">(n)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Returns a vector that is a subvector of this from element n.
</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>n</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Position of the chomp.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line213">line 213</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Vector that is subvector of this from element n.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="dot"><span class="type-signature"></span>dot<span class="signature">(value)</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Calculates the dot product (scalar product) between two vectors.
</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>value</code></td>
<td class="type">
<span class="param-type"><a href="Vector.html">Vector</a></span>
|
<span class="param-type">Array.<Number></span>
</td>
<td class="description last">Vector to be multiplied by this one.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line196">line 196</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Scalar representing the dot product.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="elementMultiply"><span class="type-signature"></span>elementMultiply<span class="signature">(value)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Multiply this vector by the vector provided element by element.
</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>value</code></td>
<td class="type">
<span class="param-type">Array.<Number></span>
|
<span class="param-type"><a href="Vector.html">Vector</a></span>
</td>
<td class="description last">Vector to multiply by this one.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line173">line 173</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Vector result of multiplication of both.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="forEach"><span class="type-signature"></span>forEach<span class="signature">(fn)</span><span class="type-signature"></span></h4>
<div class="description">
Iterate every element of the vector, and executed the provided function
for each 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>fn</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Function with signature (element, index).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line82">line 82</a>
</li></ul></dd>
</dl>
<h4 class="name" id="log"><span class="type-signature"></span>log<span class="signature">()</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Return a vector where every element is the natural logarithm of the
input element.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line127">line 127</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Result vector.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(fn)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Creates a new vector where each element is the element of this vector,
but operated by a function.
</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>fn</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Function with signature (element, index).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line95">line 95</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New vector result of apply the function to each element.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="runOperation"><span class="type-signature"></span>runOperation<span class="signature">(operand, operator)</span><span class="type-signature"></span></h4>
<div class="description">
Run an binary operation over this vector.
</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>operand</code></td>
<td class="type">
<span class="param-type">Number</span>
|
<span class="param-type">Array.<Number></span>
|
<span class="param-type"><a href="Vector.html">Vector</a></span>
</td>
<td class="description last">Scalar o vector to operate this with.</td>
</tr>
<tr>
<td class="name"><code>operator</code></td>
<td class="type">
<span class="param-type">Fucntion</span>
</td>
<td class="description last">Operator binary function with
signature (operandElement, thisElement, index)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line109">line 109</a>
</li></ul></dd>
</dl>
<h4 class="name" id="subtract"><span class="type-signature"></span>subtract<span class="signature">(value)</span><span class="type-signature"> → {<a href="Vector.html">Vector</a>}</span></h4>
<div class="description">
Return a new Vector that is the result of this - value.
</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>value</code></td>
<td class="type">
<span class="param-type"><a href="Vector.html">Vector</a></span>
</td>
<td class="description last">Vector to subtract from this one.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line136">line 136</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Result vector that is this - value.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Vector.html">Vector</a></span>
</dd>
</dl>
<h4 class="name" id="sum"><span class="type-signature"></span>sum<span class="signature">()</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Returns the sum of all the elements of the Vector.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="math_vector.js.html">math/vector.js</a>, <a href="math_vector.js.html#line160">line 160</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Sum of all the vector elements.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</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>