JavaScript:实现字符串衡量两个样本相似性的统计数据算法
/* The Sørensen–Dice coefficient is a statistic used to gauge the similarity of two samples.
* Applied to strings, it can give you a value between 0 and 1 (included) which tells you how similar they are.
* Dice coefficient is calculated by comparing the bigrams of both strings,
* a bigram is a substring of the string of length 2.
*/
// Time complexity: O(m + n), m and n being the sizes of string A and string B
// Find the bistrings of a string and return a hashmap (key => bistring, value => count)
function mapBigrams