LevenshteinTextSummary { public static int calcDistance(String strA, String strB) { final Word[] wordsA = prepareString(strA); final Word[] wordsB = prepareString(strB); return calcDistance(wordsA, wordsB); } private  LevenshteinTextSummary(); static int getThreshold(); static void setThreshold(int threshold); static Word[] prepareString(String str); static Word[] prepareStringToken(String str); static String summarizeStrings(String first, String second); static int calcDistance(String strA, String strB); static int calcDistance(Word[] wordsA, Word[] wordsB);  }
@Test public void testCalcDistanceStringString() { final String str1 = "hello"; final String str2 = "hello"; final int expectedDistance = 0; int resDis = LevenshteinTextSummary.calcDistance(str1, str2); assertEquals("Distance of 0 since inputs are the same.", expectedDistance, resDis); }
@Test public void testCalcDistanceStringString2() { final String str1 = "hello world"; final String str2 = "hello world"; final int expectedDistance = 0; int resDis = LevenshteinTextSummary.calcDistance(str1, str2); assertEquals("Distance of 0 since inputs are the same.", expectedDistance, resDis); }
@Test public void testCalcDistanceStringStringExtraWord() { final String str1 = "hello foo world"; final String str2 = "hello world"; final int expectedDistance = 1; int resDis = LevenshteinTextSummary.calcDistance(str1, str2); assertEquals("Distance of 1 with an extra word in the middle.", expectedDistance, resDis); }
@Test public void testCalcDistanceStringStringDifferentWordOrder() { final String str1 = "hello foo world"; final String str2 = "hello world koo"; final int expectedDistance = 2; int resDis = LevenshteinTextSummary.calcDistance(str1, str2); assertEquals("Distance of 2 since words are in a differnt order.", expectedDistance, resDis); }