views:

4472

answers:

7

There are similar question, but not regarding C# libraries I can use in my source code.

Thank you all for your help.

I've already saw lucene, but I need something more easy to search for similar strings and without the overhead of the indexing part.

The answer I marked has got two very easy algorithms, and one uses LINQ too, so it's perfect.

A: 

The Beagle Project for Linux is written in c# (mono) and is a google-desktop like search tool. It may have some code in there for these kind of string matching.

If I recall correctly, it uses the Lucene library for searching and retrieving data. Maybe that can be useful for your project too.

Isak Savo
+1  A: 

Have you taken a look at Lucene.net? It is a port of the Java Lucene search engine API to the .Net platform. That library offers a lot of search functionality. I played around with it a year or so ago, so don't take my suggestion as based on tons of experience. I saw it in the book Windows Developer Power Tools and took it for a test drive. You might look through their API documentation to see if it offers something like the Fuzzy Search for which you are looking.

Jason Jackson
Could you please tell how to get the degree of similarity using Lucene?
Jenea
Sorry, I have not used it professionally. As I mentioned in my post, I just played around with it probably around 2007/2008.
Jason Jackson
A: 

This code project paper has a string similarity function using the Levenshtein distance.

Ed Schwehm
+1  A: 

There is the following Levenshtein Distance Algorithm which assigns a value to the similarity of two strings (well, the difference actually), that could be used to build upon: http://www.merriampark.com/ldcsharp.htm.

benefactual
+10  A: 

Levenshtein distance implementation:

I have a .NET 1.1 project in which I use the latter. It's simplistic, but works perfectly for what I need. From what I remember it needed a bit of tweaking, but nothing that wasn't obvious.

George Mauer
Why do you say "Using LINQ" ? None of these implementations uses Linq...
Thomas Levesque
Actually these implementations are identical, except that the latter uses Substring, which is much slower than using the indexer because it creates new String instances each time...
Thomas Levesque
Indeed you are correct. I could have sworn that there was some LINQ-love in it, or at least that the headline claimed it was LINQy or something.
George Mauer
A: 

Hello,

I have used "Ternary Search Tree Dictionary in C#" (http://www.codeproject.com/KB/recipes/tst.aspx) to search for similar strings.

Regards, Patricio

+8  A: 

you can also look at the very impressive library titled Sam's String Metrics http://www.dcs.shef.ac.uk/~sam/stringmetrics.html. this includes a host of algorithms.

  • Hamming distance
  • Levenshtein distance
  • Needleman-Wunch distance or Sellers Algorithm
  • Smith-Waterman distance
  • Gotoh Distance or Smith-Waterman-Gotoh distance
  • Block distance or L1 distance or City block distance
  • Monge Elkan distance
  • Jaro distance metric
  • Jaro Winkler
  • SoundEx distance metric
  • Matching Coefficient
  • Dice’s Coefficient
  • Jaccard Similarity or Jaccard Coefficient or Tanimoto coefficient
  • Overlap Coefficient
  • Euclidean distance or L2 distance
  • Cosine similarity
  • Variational distance
  • Hellinger distance or Bhattacharyya distance
  • Information Radius (Jensen-Shannon divergence)
  • Harmonic Mean
  • Skew divergence
  • Confusion Probability
  • Tau
  • Fellegi and Sunters (SFS) metric
  • TFIDF or TF/IDF
  • FastA
  • BlastP
  • Maximal matches
  • q-gram
  • Ukkonen Algorithms
Zaffiro