How to determine which row in an array is most similar to a given row?

Given the line,

string name = "Michael";

I want to evaluate which string in the array is most similar:

string[] names = new[] { "John", "Adam", "Paul", "Mike", "John-Michael" };

I want to create a message for the user: “We could not find Michael, but John Michael is close. Did you mean this? How can I make this determination?

+3
source share
2 answers

Here you have the results for your example using the Levenshtein distance:

EditDistance["Michael",#]&/@{"John","Adam","Paul","Mike","John-Michael"}
{6,6,5,4,5}  

Here you have results using the Smith-Waterman affinity test.

SmithWatermanSimilarity["Michael",#]&/@{"John","Adam","Paul","Mike","John-Michael"}
{0.,0.,0.,2.,7.} 

NTN!

+3
source

Edit/Levenshtein , , .

, # .

+5

Source: https://habr.com/ru/post/1788000/


All Articles