With Commons Lang api I can calculate the similarity between two strings through the LevensteinDistance. The result is the number of changes needed to change one string into another. I wish the result was within the range from 0 to 1, where it would be easier to identify the similarity between the strings. The result would be closer to 0 great similarity. Is it possible?
Below the example I'm using:
public class TesteLevenstein {
public static void main(String[] args) {
int distance1 = StringUtils.getLevenshteinDistance("Boat", "Coat");
int distance2 = StringUtils.getLevenshteinDistance("Remember", "Alamo");
int distance3 = StringUtils.getLevenshteinDistance("Steve", "Stereo");
System.out.println("distance(Boat, Coat): " + distance1);
System.out.println("distance(Remember, Alamo): " + distance2);
System.out.println("distance(Steve, Stereo): " + distance3);
}
}
Thanks!