Bixby Developer Center

References

textLib

Provides various text-related functions, especially related to fuzzy matching.

Caution

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.

textLib~fuzzyMatch(str1, str2, [distance])

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: BooleanAccess: Public

ParameterTypeDefaultDescription
str1StringInput to be checked
str2StringInput to check, or user input
[ distance ]Number2If negative, attempts a case-insensitive punctuation-insensitive match

textLib~spaceMixedCase(str)

Takes a mixedCase enum string and inserts spaces, for example "SouthAfrican" to "South African"

Kind: Inner method of textLib
Returns: StringAccess: Public

ParameterType
strString

textLib~levenshteinDistance(str1, str2)

Compute the Levenshtein distance between two strings. This implementation of the algorithm is based on Wikipedia pseudo-code.

Kind: Inner method of textLib
Returns: NumberAccess: Public
See: Levenshtein Distance Wikipedia Page

ParameterType
str1String
str2String

textLib~stemAllWords(str)

Stem all the words in the given string. This uses Porter stemming.

Kind: Inner method of textLib
Returns: Array.StringAccess: Public

ParameterTypeDescription
strStringThe word to stem.

textLib~stripHtml(str)

Strip embedded HTML from the string

Kind: Inner method of textLib
Returns: StringAccess: Public

ParameterType
strString