You are here
Home > Java > Java Program to Check Two Strings Similarity

Java Program to Check Two Strings Similarity

Hello Friends, I hope you are doing fine. Today I am sharing java program to check two strings similarity. Actually yesterday I was working on a project in which I had to find similarity between two strings in percent. There are many algorithms available to do this and some of them are as follows:

  1. Levenshtein edit distance
  2. Damerau–Levenshtein distance
  3. Jaro-Winkler similarity
  4. Longest common subsequence problem
  5. Hamming distance

I used Jaro-Winkler’s algorithm in my project because it fits better in my project, but I am sharing Levenshtein edit distance based program also. So, here is the codes and their output below.

StringEqualityPercentCheckLevenshteinDistance.java

Output

String Equality Percent Check Levenshtein Distance
String Equality Percent Check Levenshtein Distance

StringEqualityPercentCheckUsingJaroWinklerDistance.java

Output

String Equality Percent Check Using Jaro-Winkler Distance
String Equality Percent Check Using Jaro-Winkler Distance

References

https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/src-html/org/apache/commons/lang/StringUtils.html#line.6162

https://commons.apache.org/sandbox/commons-text/jacoco/org.apache.commons.text.similarity/JaroWinklerDistance.java.html

 

Thanks! Please share if you like it

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.
https://www.zatackcoder.com

Comments

zatackcoder
Top

  Â