Helper
Methods
returnIndexer
Returns an Indexer object that contains two functions. The first function build()
incrementally builds an index for each element using itsIndex — both passed as
parameters to it. The second function — result() allows accessing the index anytime.
It is typically used with string.soc, string.bong, string.song, and tokens.sow.
Example
var indexer = returnIndexer();
// -> { build: [function], result: [function] }
Returns
used to build and access the index.
- Type
 - indexer
 
returnQuotedTextExtractor
Returns a function that extracts all occurrences of every quoted text
between the lq and the rq characters from its argument. This argument
must be of type string.
Example
var extractQuotedText = returnQuotedTextExtractor();
extractQuotedText( 'Raise 2 issues - "fix a bug" & "run tests"' );
// -> [ 'fix a bug', 'run tests' ]
    Parameters
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
| lq | string | 
                
                    <optional> | 
            
            
                '"' | the left quote character.  | 
        
| rq | string | 
                
                    <optional> | 
            
            
                '"' | the right quote character.  | 
        
Returns
that will accept an input string argument and return an
array of all substrings that are quoted between lq and rq.
- Type
 - function
 
returnWordsFilter
Returns an object containing the following functions: (a) set(), which returns
a set of mapped words given in the input array words. (b) exclude() that
is suitable for array filtering operations.
If the second argument mappers is provided as an array of maping functions
then these are applied on the input array before converting into a set. A
mapper function must accept a string as argument and return a string as the result.
Examples of mapper functions are typically string functionss of wink-nlp-utils
such as string.lowerCase(), string.stem() and
string.soundex().
Example
var stopWords = [ 'This', 'That', 'Are', 'Is', 'Was', 'Will', 'a' ];
var myFilter = returnWordsFilter( stopWords, [ string.lowerCase ] );
[ 'this', 'is', 'a', 'cat' ].filter( myFilter.exclude );
// -> [ 'cat' ]
    Parameters
| Name | Type | Attributes | Description | 
|---|---|---|---|
| words | Array.<string> | that can be filtered using the returned wordsFilter.  | 
        |
| mappers | Array.<function()> | 
                
                    <optional> | 
            
            
            optionally used to map each word before creating the wordsFilter.  | 
        
Returns
object containg set() and exclude() functions for words.
- Type
 - wordsFilter