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ᴏʀʏ
  • 101,556
  • 20
  • 162
  • 188
SunilRai86
  • 902
  • 5
  • 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
  • 9,848
  • 2
  • 38
  • 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
  • 174
  • 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,525
  • 5
  • 65
  • 89