我试图使用Levenshtein Distance的帮助来在OCR页面上查找模糊关键字(静态文本)。
要做到这一点,我想给出一个允许的错误百分比(比如15%)。模糊匹配字符串中的多个单词
string Keyword = "past due electric service";
由于关键字是25个字符长,我想允许4个错误(25 * 0.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. "
这是我怎么做,现在......
int LevenshteinDistance = LevenshteinAlgorithm(Keyword, Entire_OCR_Page); // = 202
int NumberOfErrorsAllowed = 4;
int Allowance = (Entire_OCR_Page.Length() - Keyword.Length()) + NumberOfErrorsAllowed; // = 205
显然,Keyword
没有在OCR_Text
找到(它不应该)。但是,使用Levenshtein的距离,错误的数量少于15%的余地(因此我的逻辑表示它被发现)。
有谁知道更好的方法来做到这一点?
发布了一个更好的问题。 http://goo.gl/Rb6ejp – Milne