_classify
protected
static
Array
_classify
(
string
)
Returns a character classification map for the specified string.
- Parameters:
-
string <String>
String to classify.
- Returns:
Array
- Classification map.
_isWordBoundary
protected
static
Boolean
_isWordBoundary
(
map
,
index
)
Returns
true
if there is a word boundary after the specified
character index, false
otherwise.
- Parameters:
-
map <Array>
Character classification map generated by_classify
. -
index <Number>
Character index to test.
getUniqueWords
static
Array
getUniqueWords
(
string
,
options
)
Returns an array containing only unique words from the specified string.
For example, the string
'foo bar baz foo'
would result in
the array ['foo', 'bar', 'baz']
.
- Parameters:
-
string <String>
String to split. -
options <Object>
(optional) Options (seegetWords()
for details).
- Returns:
Array
- Array of unique words.
getWords
static
Array
getWords
(
string
,
options
)
Splits the specified string into an array of individual words.
- Parameters:
-
string <String>
String to split. -
options <Object>
(optional) Options object containing zero or more of the following properties:- ignoreCase (Boolean)
-
If
true
, the string will be converted to lowercase before being split. Default isfalse
. - includePunctuation (Boolean)
-
If
true
, the returned array will include punctuation characters. Default isfalse
. - includeWhitespace (Boolean)
-
If
true
, the returned array will include whitespace characters. Default isfalse
.
- Returns:
Array
- Array of words.
isWordBoundary
static
Boolean
isWordBoundary
(
string
,
index
)
Returns
true
if there is a word boundary after the specified
character index in the given string, false
otherwise.
- Parameters:
-
string <String>
String to test. -
index <Number>
Character index to test within the string.
- Returns:
Boolean
true
for a word boundary,false
otherwise.