bravey
Version:
A simple JavaScript NLP-like library to help you creating your own bot.
1,430 lines (397 loc) • 18.8 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Namespace: Text</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">Namespace: Text</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="Bravey.html">Bravey</a>.</span>Text</h2>
</header>
<article>
<div class="container-overview">
<div class="description">Text parsing and tokenizing related functions.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line5">line 5</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="Bravey.Text.RegexMap.html">RegexMap</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".calculateScore"><span class="type-signature">(static) </span>calculateScore<span class="signature">(match, positions)</span><span class="type-signature"> → {number}</span></h4>
<div class="description">
Counts the not empty <tt>positions</tt> of <tt>match</tt>.
</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>match</code></td>
<td class="type">
<span class="param-type">Array.<string></span>
</td>
<td class="description last">The array to check.</td>
</tr>
<tr>
<td class="name"><code>positions</code></td>
<td class="type">
<span class="param-type">Array.<number></span>
</td>
<td class="description last">The positions to check.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line30">line 30</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The count of filled positions.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".clean"><span class="type-signature">(static) </span>clean<span class="signature">(text)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Clean text from diactrics, trims, removes double spaces and converts to lower case.
</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>text</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The text to be cleaned</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line119">line 119</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The cleaned text.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".entityTrim"><span class="type-signature">(static) </span>entityTrim<span class="signature">(ent)</span><span class="type-signature"> → {<a href="global.html#Entity">Entity</a>}</span></h4>
<div class="description">
Trims a structured entity, usually produced by an entity recognizer. It moves the entity starting position and changes its string to its trimmed version.
</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>ent</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Entity">Entity</a></span>
</td>
<td class="description last">The entity 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="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line42">line 42</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The trimmed entity.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#Entity">Entity</a></span>
</dd>
</dl>
<h4 class="name" id=".generateGUID"><span class="type-signature">(static) </span>generateGUID<span class="signature">()</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Generate a random GUID.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line15">line 15</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The generated GUID.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".pad"><span class="type-signature">(static) </span>pad<span class="signature">(n, width, z<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Adds zeroes to the left of <tt>n</tt> until the length <tt>width</tt> is reached.
</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>n</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The number to be padded.</td>
</tr>
<tr>
<td class="name"><code>width</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The string length to be reached.</td>
</tr>
<tr>
<td class="name"><code>z</code></td>
<td class="type">
<span class="param-type">z</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
"0"
</td>
<td class="description last">The symbol to be used for padding.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line130">line 130</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The padded value of <tt>n</tt>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".removeDiacritics"><span class="type-signature">(static) </span>removeDiacritics<span class="signature">(text)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
Remove diatrics from a sentence, replacing them with not-diatrics representation.
</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>text</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The 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="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line153">line 153</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The text without diatrics.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id=".tokenize"><span class="type-signature">(static) </span>tokenize<span class="signature">(text)</span><span class="type-signature"> → {Array.<string>}</span></h4>
<div class="description">
Tokenize a string, splitting for non-words.
</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>text</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The string to be tokenized.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line141">line 141</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The tokenized string.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<string></span>
</dd>
</dl>
<h4 class="name" id=".unique"><span class="type-signature">(static) </span>unique<span class="signature">(list)</span><span class="type-signature"> → {Array.<string>}</span></h4>
<div class="description">
Returns unique values of an 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>list</code></td>
<td class="type">
<span class="param-type">Array.<string></span>
</td>
<td class="description last">The array 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="extras_text.js.html">extras/text.js</a>, <a href="extras_text.js.html#line101">line 101</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Unique values of <tt>list</tt>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<string></span>
</dd>
</dl>
</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>