Bixby Developer Center

Guides

textLib

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

var textLib = require('textLib');

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, e.g. "SouthAfrican" --> "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: http://en.wikipedia.org/wiki/Levenshtein_distance

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