Provides various text-related functions, especially related to fuzzy matching.
This module is being deprecated and will be removed in a future version of the Bixby JavaScript API. It is not supported in JavaScript Runtime Version 2.
Importing with JavaScript Runtime Version 1:
var textLib = require('textLib')
The following sections describe the available methods within this module. Each section includes a table that lists the parameters for that method, as well as the parameter's type and description.
Perform a fuzzy string comparison using case-insensitive and punctuation-insensitive Levenshtein distance.
Input order matters, with str2
considered the "input to check", (the user's request). This means that str2
must be completely contained within str1
, within the distance threshold, but not vice versa. With a distance of two, this results in "cheeseburgers" matching "cheeseburger", but not "burger", even though it's included in the user's input. It will also match "chicken salad" to "caesar salad with grilled chicken", as all of the input is included in the match.
Kind: Inner method of textLib
Returns: Boolean
Access: Public
Parameter | Type | Default | Description |
---|---|---|---|
str1 | String | Input to be checked | |
str2 | String | Input to check, or user input | |
[ distance ] | Number | 2 | If negative, attempts a case-insensitive punctuation-insensitive match |
Takes a mixedCase enum string and inserts spaces, for example "SouthAfrican" to "South African"
Kind: Inner method of textLib
Returns: String
Access: Public
Parameter | Type |
---|---|
str | String |
Compute the Levenshtein distance between two strings. This implementation of the algorithm is based on Wikipedia pseudo-code.
Kind: Inner method of textLib
Returns: Number
Access: Public
See: Levenshtein Distance Wikipedia Page
Parameter | Type |
---|---|
str1 | String |
str2 | String |
Stem all the words in the given string. This uses Porter stemming.
Kind: Inner method of textLib
Returns: Array.String
Access: Public
Parameter | Type | Description |
---|---|---|
str | String | The word to stem. |
Strip embedded HTML from the string
Kind: Inner method of textLib
Returns: String
Access: Public
Parameter | Type |
---|---|
str | String |