(bigrams, string)
| 21 | // Calculate the number of common bigrams between a map of bigrams and a string |
| 22 | |
| 23 | function countCommonBigrams(bigrams, string) { |
| 24 | let count = 0 |
| 25 | for (let i = 0; i < string.length - 1; i++) { |
| 26 | const bigram = string.substring(i, i + 2) |
| 27 | if (bigrams.has(bigram)) count++ |
| 28 | } |
| 29 | return count |
| 30 | } |
| 31 | |
| 32 | // Calculate Dice coeff of 2 strings |
| 33 | function diceCoefficient(stringA, stringB) { |