Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene.NET (strings fuzzy matching)

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

like image 260
user306080 Avatar asked Mar 31 '10 14:03

user306080


1 Answers

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 
} 
like image 139
Mikos Avatar answered Sep 27 '22 21:09

Mikos