-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(*): complete JSDoc for tokens- bigrams & appendBigrams
- Loading branch information
sanjayaksaxena
committed
Oct 14, 2017
1 parent
0f1e91f
commit 7c83653
Showing
8 changed files
with
335 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.