Tag: levenshtein 距离

模糊匹配字符串中的多个单词

我正在尝试使用Levenshtein Distance的帮助在OCR页面上找到模糊关键字(静态文本)。 为此,我想给出允许的一定百分比的错误(比如15%)。 string Keyword = “past due electric service”; 由于关键字长度为25个字符,我想允许4个错误(25 * .15向上舍入) 我需要能够将它与…进行比较 string Entire_OCR_Page = “previous bill amount payment received on 12/26/13 thank you! current electric service total balances unpaid 7 days after the total due date are subject to a late charge of 7.5% of the amount due or $2.00, whichever/5 greater. […]

Damerau – Levenshtein距离,增加一个门槛

我有以下实现,但我想添加一个阈值,所以如果结果将大于它,只需停止计算并返回。 我该怎么办呢? 编辑:这是我目前的代码, threshold尚未使用…目标是它被使用 public static int DamerauLevenshteinDistance(string string1, string string2, int threshold) { // Return trivial case – where they are equal if (string1.Equals(string2)) return 0; // Return trivial case – where one is empty if (String.IsNullOrEmpty(string1) || String.IsNullOrEmpty(string2)) return (string1 ?? “”).Length + (string2 ?? “”).Length; // Ensure string2 (inner cycle) is longer […]