Skip to content

Commit

Permalink
docs(*): complete JSDoc for tokens- bigrams & appendBigrams
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayaksaxena committed Oct 14, 2017
1 parent 0f1e91f commit 7c83653
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 247 deletions.
2 changes: 2 additions & 0 deletions docs-toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ toc:
- string.trim
- string.upperCase
- name: tokens
- tokens.appendBigrams
- tokens.bigrams
- tokens.bow
- tokens.phonetize
- tokens.propagateNegations
Expand Down
186 changes: 183 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,26 @@ <h3 class='mb0 no-anchor'>wink-nlp-utils</h3>
</li>


<li><a
href='#tokensappendbigrams'
class="">
tokens.appendBigrams

</a>

</li>


<li><a
href='#tokensbigrams'
class="">
tokens.bigrams

</a>

</li>


<li><a
href='#tokensbow'
class="">
Expand Down Expand Up @@ -2635,6 +2655,166 @@ <h2 id='tokens' class='mt0'>



<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='tokensappendbigrams'>
tokens.appendBigrams
</h3>


</div>


<p>Generates bigrams from the input tokens and appends them to the input tokens.</p>


<div class='pre p1 fill-light mt0'>tokens.appendBigrams</div>











<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>tokens</span> <code class='quiet'>(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>>)</code>
— the input tokens.

</div>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>></code>:
the input tokens appended with their bigrams.








<div class='py1 quiet mt1 prose-big'>Example</div>


<pre class='p1 overflow-auto round fill-light'>appendBigrams( [ <span class="hljs-string">'he'</span>, <span class="hljs-string">'acted'</span>, <span class="hljs-string">'decisively'</span>, <span class="hljs-string">'today'</span> ] );
<span class="hljs-comment">// -&gt; [ 'he',</span>
<span class="hljs-comment">// 'acted',</span>
<span class="hljs-comment">// 'decisively',</span>
<span class="hljs-comment">// 'today',</span>
<span class="hljs-comment">// 'he_acted',</span>
<span class="hljs-comment">// 'acted_decisively',</span>
<span class="hljs-comment">// 'decisively_today' ]</span></pre>








</section>




<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='tokensbigrams'>
tokens.bigrams
</h3>


</div>


<p>Generates bigrams from the input tokens.</p>


<div class='pre p1 fill-light mt0'>tokens.bigrams</div>











<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>tokens</span> <code class='quiet'>(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>>)</code>
— the input tokens.

</div>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>></code>:
the bigrams.








<div class='py1 quiet mt1 prose-big'>Example</div>


<pre class='p1 overflow-auto round fill-light'>bigrams( [ <span class="hljs-string">'he'</span>, <span class="hljs-string">'acted'</span>, <span class="hljs-string">'decisively'</span>, <span class="hljs-string">'today'</span> ] );
<span class="hljs-comment">// -&gt; [ [ 'he', 'acted' ],</span>
<span class="hljs-comment">// [ 'acted', 'decisively' ],</span>
<span class="hljs-comment">// [ 'decisively', 'today' ] ]</span></pre>








</section>




<section class='p2 mb2 clearfix bg-white minishadow'>


Expand Down Expand Up @@ -2818,7 +2998,7 @@ <h3 class='fl m0' id='tokensphonetize'>


<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#string">string</a></code>:
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>></code>:
phonetized tokens.


Expand Down Expand Up @@ -3083,7 +3263,7 @@ <h3 class='fl m0' id='tokenssoundex'>


<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#string">string</a></code>:
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>></code>:
soundex coded tokens.


Expand Down Expand Up @@ -3273,7 +3453,7 @@ <h3 class='fl m0' id='tokensstem'>


<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="#string">string</a></code>:
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="#string">string</a>></code>:
stemmed tokens.


Expand Down
54 changes: 54 additions & 0 deletions src/tokens-append-bigrams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// wink-nlp-utils
// NLP Functions for removing HTML Tags, Managing Elisions,
// NGrams, appendBigramsming, Phoneticising to Tokenizating and more.
//
// Copyright (C) 2017 GRAYPE SyappendBigramss Private Limited
//
// This file is part of “wink-nlp-utils”.
//
// “wink-nlp-utils” is free software: you can redistribute it
// and/or modify it under the terms of the GNU Affero
// General Public License as published by the Free
// Software Foundation, version 3 of the License.
//
// “wink-nlp-utils” is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General
// Public License for more details.
//
// You should have received a copy of the GNU Affero
// General Public License along with “wink-nlp-utils”.
// If not, see <http://www.gnu.org/licenses/>.

//

// ## tokens

// ### appendBigrams
/**
*
* Generates bigrams from the input tokens and appends them to the input tokens.
*
* @name tokens.appendBigrams
* @param {string[]} tokens — the input tokens.
* @return {string[]} the input tokens appended with their bigrams.
* @example
* appendBigrams( [ 'he', 'acted', 'decisively', 'today' ] );
* // -> [ 'he',
* // 'acted',
* // 'decisively',
* // 'today',
* // 'he_acted',
* // 'acted_decisively',
* // 'decisively_today' ]
*/
var appendBigrams = function ( tokens ) {
var i, imax;
for ( i = 0, imax = tokens.length - 1; i < imax; i += 1 ) {
tokens.push( tokens[ i ] + '_' + tokens[ i + 1 ] );
}
return tokens;
}; // appendBigrams()

module.exports = appendBigrams;
54 changes: 54 additions & 0 deletions src/tokens-bigrams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// wink-nlp-utils
// NLP Functions for removing HTML Tags, Managing Elisions,
// NGrams, bigramsming, Phoneticising to Tokenizating and more.
//
// Copyright (C) 2017 GRAYPE Sybigramss Private Limited
//
// This file is part of “wink-nlp-utils”.
//
// “wink-nlp-utils” is free software: you can redistribute it
// and/or modify it under the terms of the GNU Affero
// General Public License as published by the Free
// Software Foundation, version 3 of the License.
//
// “wink-nlp-utils” is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General
// Public License for more details.
//
// You should have received a copy of the GNU Affero
// General Public License along with “wink-nlp-utils”.
// If not, see <http://www.gnu.org/licenses/>.

//

// ## tokens

// ### bigrams
/**
*
* Generates bigrams from the input tokens.
*
* @name tokens.bigrams
* @param {string[]} tokens — the input tokens.
* @return {string[]} the bigrams.
* @example
* bigrams( [ 'he', 'acted', 'decisively', 'today' ] );
* // -> [ [ 'he', 'acted' ],
* // [ 'acted', 'decisively' ],
* // [ 'decisively', 'today' ] ]
*/
var bigrams = function ( tokens ) {
// Bigrams will be stored here.
var bgs = [];
// Helper variables.
var i, imax;
// Create bigrams.
for ( i = 0, imax = tokens.length - 1; i < imax; i += 1 ) {
bgs.push( [ tokens[ i ], tokens[ i + 1 ] ] );
}
return bgs;
}; // bigrams()

module.exports = bigrams;
2 changes: 1 addition & 1 deletion src/tokens-phonetize.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var stringPhonetize = require( './string-phonetize.js' );
*
* @name tokens.phonetize
* @param {string[]} tokens — the input tokens.
* @return {string} phonetized tokens.
* @return {string[]} phonetized tokens.
* @example
* phonetize( [ 'he', 'acted', 'decisively', 'today' ] );
* // -> [ 'h', 'aktd', 'dssvl', 'td' ]
Expand Down
2 changes: 1 addition & 1 deletion src/tokens-soundex.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var stringSoundex = require( './string-soundex.js' );
*
* @name tokens.soundex
* @param {string[]} tokens — the input tokens.
* @return {string} soundex coded tokens.
* @return {string[]} soundex coded tokens.
* @example
* soundex( [ 'he', 'acted', 'decisively', 'today' ] );
* // -> [ 'H000', 'A233', 'D221', 'T300' ]
Expand Down
2 changes: 1 addition & 1 deletion src/tokens-stem.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var porter2Stemmer = require( 'wink-porter2-stemmer' );
*
* @name tokens.stem
* @param {string[]} tokens — the input tokens.
* @return {string} stemmed tokens.
* @return {string[]} stemmed tokens.
* @example
* stem( [ 'he', 'acted', 'decisively', 'today' ] );
* // -> [ 'he', 'act', 'decis', 'today' ]
Expand Down

0 comments on commit 7c83653

Please sign in to comment.