开发者

Lucene.NET (strings fuzzy matching)

开发者 https://www.devze.com 2022-12-25 10:36 出处:网络
Could anyone give me an example about how to do 开发者_JAVA技巧fuzzy matching of two strings using Lucene.NET (or using Java version of Lucene, or in any other language that has port of Lucene).Could

Could anyone give me an example about how to do 开发者_JAVA技巧fuzzy matching of two strings using Lucene.NET (or using Java version of Lucene, or in any other language that has port of Lucene).


Could you be a bit more specific on what you mean by fuzzy matching?

Lucene offers fuzzy queries using the tilde(~) operator and the wildcards (* & ?) See here

If you want to compare string distance of 2 strings using methods such as Levenshtein, Jaro-Winkler etc. you are better off using a separate library such as SimMetrics. I use Simmetrics in my production site and it works fab.

SimMetricsMetricUtilities.Levenstein ls = new SimMetricsMetricUtilities.Levenstein(); //compare string 1, string 2 
double sim = ls.GetSimilarity(string_1, string_2); 
if(sim > [some value]) 
{ 
//do something 
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号