(str1, str2)
| 4791 | var GRAM_SIZE_LOWER = 2; |
| 4792 | var GRAM_SIZE_UPPER = 3; |
| 4793 | function _distance(str1, str2) { |
| 4794 | if (str1 === null && str2 === null) { |
| 4795 | throw "Trying to compare two null values"; |
| 4796 | } |
| 4797 | if (str1 === null || str2 === null) |
| 4798 | return 0; |
| 4799 | str1 = String(str1); |
| 4800 | str2 = String(str2); |
| 4801 | const distance = levenshtein(str1, str2); |
| 4802 | if (str1.length > str2.length) { |
| 4803 | return 1 - distance / str1.length; |
| 4804 | } else { |
| 4805 | return 1 - distance / str2.length; |
| 4806 | } |
| 4807 | } |
| 4808 | function levenshtein(str1, str2) { |
| 4809 | const current2 = []; |
| 4810 | let prev; |
no test coverage detected