1

I want to compare two strings, such as:

 str1 = "this is a dynamic data";
 str2 = "this is a <data_1> data";

Is there any method that will find the nearest match? I have used Ternary Search Tree (TST) Dictionary functions. Are there any other ways to do this kind of thing?

Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
SunilRai86
  • 990
  • 6
  • 16
  • 26

3 Answers3

1

There is no such method in BCL that finds nearest match of the string. But you can roll your own. read about "Levenshtein Distance" on the following link

crypted
  • 10,118
  • 3
  • 39
  • 52
1

In am not sure about this thing in C#, but yes that is there in SQL,

select difference('this is a dynamic data','this is a dynamic')
user765671
  • 154
  • 7
1

What about the Jaccard similarity coefficient? http://en.wikipedia.org/wiki/Jaccard_index

It's easy to implement and gives a good similarity score. You have to tokenize your sentences though ;)

Thomas Jungblut
  • 20,854
  • 6
  • 68
  • 91