Namespace String.metrics
Contains methods to compute string metrics.
Defined in: string.metrics.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
String.metrics.exports.metrics.fraction(str1, str2, distance)
Compute the distance between two strings as a fraction of the length of the longer of the two strings. |
<static> |
String.metrics.exports.metrics.levenshteinDistance(str1, str2)
Compute the Levenshtein distance between two strings. |
<static> |
String.metrics.exports.metrics.levenshteinFraction(str1, str2)
Compute the Levenshtein distance between two strings as a fraction of the length of the longer of the two strings. |
Method Detail
<static>
{Number}
String.metrics.exports.metrics.fraction(str1, str2, distance)
Compute the distance between two strings as a fraction of the length of the longer of the two strings.
- Parameters:
- {String} str1
- One of the strings to score against.
- {String} str2
- One of the strings to score against.
- {Number|Function} distance
- An integer distance between strings, or a function to compute the distance.
- Returns:
- {Number} Returns the computed distance between the two argument strings as a fraction.
<static>
{Number}
String.metrics.exports.metrics.levenshteinDistance(str1, str2)
Compute the Levenshtein distance between two strings.
- Parameters:
- {String} str1
- One of the strings to score against.
- {String} str2
- One of the strings to score against.
- Returns:
- {Number} Returns the computed Levenshtein distance between the two argument strings.
- See:
- Source: Wikibooks:Algorithm Implementation/Strings/Levenshtein distance
- Wikipedia: Levenshtein distance
<static>
{Number}
String.metrics.exports.metrics.levenshteinFraction(str1, str2)
Compute the Levenshtein distance between two strings as a fraction of the length of the longer of the two strings. .
- Parameters:
- {String} str1
- One of the strings to score against.
- {String} str2
- One of the strings to score against.
- Returns:
- {Number} Returns the computed distance between the two argument strings as a fraction.