I have an input string and a collection of strings and I want to compare the input string and find the best choices to view.I want to write a function that tell me how much this two string are similar.have you any idea?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For ‘short’ string differences the algorithm you are searching for is called:
Levenshtein distance
http://en.wikipedia.org/wiki/Levenshtein_distance
For seeking differences in sentences you may wish to check for algorithms that solve the ‘longest common sequence‘ problem.
One tool that does that is the (originally unix) ‘diff‘