Methods
(static) calculate(str1, str2) → {number}
Calculates the Hamming distance between two strings.
Parameters:
Name | Type | Description |
---|---|---|
str1 |
string | The first string for comparison. |
str2 |
string | The second string for comparison. |
- Source:
Throws:
-
- If the strings have different lengths.
- Type
- Error
Returns:
- The Hamming distance between the two strings.
- Type
- number
(static) similarity(str1, str2) → {number}
Calculates the similarity between two strings based on their Hamming distance.
Parameters:
Name | Type | Description |
---|---|---|
str1 |
string | The first string for comparison. |
str2 |
string | The second string for comparison. |
- Source:
Returns:
- The similarity between the two strings, ranging from 0.0 (no similarity) to 1.0 (perfect similarity).
- Type
- number