Methods
calculateSimilarity(str1, str2) → {number}
Calculates the similarity between two strings using n-grams.
Parameters:
Name | Type | Description |
---|---|---|
str1 |
string | The first string to compare. |
str2 |
string | The second string to compare. |
Returns:
- A number between 0 and 1 representing the similarity between the two strings.
- Type
- number
calculateSimilarity(str1, str2) → {number}
Calculates the similarity between two strings using q-grams.
Parameters:
Name | Type | Description |
---|---|---|
str1 |
string | The first string to compare. |
str2 |
string | The second string to compare. |
Returns:
- A number between 0 and 1 representing the similarity between the two strings.
- Type
- number
getIntersection(set1, set2) → {Array.<string>}
Gets the intersection of two sets of n-grams.
Parameters:
Name | Type | Description |
---|---|---|
set1 |
Array.<string> | The first set of n-grams. |
set2 |
Array.<string> | The second set of n-grams. |
Returns:
- An array of n-grams that are present in both sets.
- Type
- Array.<string>
getIntersection(set1, set2) → {Array.<string>}
Gets the intersection of two sets of q-grams.
Parameters:
Name | Type | Description |
---|---|---|
set1 |
Array.<string> | The first set of q-grams. |
set2 |
Array.<string> | The second set of q-grams. |
Returns:
- An array of q-grams that are present in both sets.
- Type
- Array.<string>
getNgrams(str) → {Array.<string>}
Generates all n-grams from the input string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to generate n-grams from. |
Returns:
- An array of n-grams from the input string.
- Type
- Array.<string>
getQgrams(str) → {Array.<string>}
Generates all q-grams from the input string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to generate q-grams from. |
Returns:
- An array of q-grams from the input string.
- Type
- Array.<string>
getUnion(set1, set2) → {Array.<string>}
Gets the union of two sets of n-grams.
Parameters:
Name | Type | Description |
---|---|---|
set1 |
Array.<string> | The first set of n-grams. |
set2 |
Array.<string> | The second set of n-grams. |
Returns:
- An array of all unique n-grams from both sets.
- Type
- Array.<string>
getUnion(set1, set2) → {Array.<string>}
Gets the union of two sets of q-grams.
Parameters:
Name | Type | Description |
---|---|---|
set1 |
Array.<string> | The first set of q-grams. |
set2 |
Array.<string> | The second set of q-grams. |
Returns:
- An array of all unique q-grams from both sets.
- Type
- Array.<string>