Does C# has its own library for Fuzzy match(Fuzzy Search) or a method that can be used directly from .net libraries?
Asked
Active
Viewed 8,559 times
14
-
You could use a Regular Expression. – Todd Moses Feb 18 '10 at 19:16
-
19Regular Expressions arent very fuzzy – SwDevMan81 Feb 18 '10 at 19:18
-
Similar / duplicate of http://stackoverflow.com/questions/53480/fuzzy-text-sentences-titles-matching-in-c AND http://stackoverflow.com/questions/83777/are-there-any-fuzzy-search-or-string-similarity-functions-libraries-written-for-c – jjxtra Feb 19 '10 at 01:26
-
Also see this (later) question: https://stackoverflow.com/q/19123506/4858 – skst Apr 08 '20 at 04:21
3 Answers
11
Not a library, but check out the Levenshtein edit distance algorithm:
http://en.wikipedia.org/wiki/Levenshtein_distance
It's well known and established and excellent for fuzzy matching text. There are many other examples out there besides the link i provided in case it doesn't suit you: Google Search

Tom Ferguson
- 907
- 1
- 10
- 26

Paul Sasik
- 79,492
- 20
- 149
- 189
-
I know Levenshtein edit distance algorithm and I already used it but I'm wondering if .net has one. – Eyla Feb 18 '10 at 19:32
-
1Not built in. Not as of 3.5 anyway. Though it's fairly trivial to implement as is. Why not just reuse what you already know? Btw. You can add it as an extension method and make it feel like a .Net library function. ;-) – Paul Sasik Feb 18 '10 at 20:06
4
Current versions don't have it built in.
I have seen and used Soundex (a method for fuzzy matching) operations for this in the past. Here's an article on how to implement Soundex in .Net.

David
- 72,686
- 18
- 132
- 173
-
1
-
Thanks. I've bookmarked this because I want to try the Levenshtein next time I have a need for such logic. – David Feb 19 '10 at 02:46
3
If its for a kindof "did you mean" function you could have a look at Lorenzo Stoakes C# implementation of Peter Norvig's Spelling Corrector.
If you need more elaborate search features like ranking and such, you could also take at look at Lucene.Net

Tom Ferguson
- 907
- 1
- 10
- 26

Luhmann
- 3,860
- 26
- 33