LevenshteinComparator extends TextSimilarityMeasureBase { @Override public double getSimilarity(String s1, String s2) throws SimilarityException { return computeLevenshteinDistance(s1, s2); } LevenshteinComparator(); @Override double getSimilarity(String s1, String s2); @Override double getSimilarity(Collection<String> strings1, Collection<String> strings2);  }
@Test public void test() throws Exception { String a1 = "test String1"; String a2 = "test String2"; String b1 = "This is my string"; String b2 = "That is your string"; TermSimilarityMeasure measure = new LevenshteinComparator(); assertEquals(1, measure.getSimilarity(a1, a2), epsilon); assertEquals(6, measure.getSimilarity(b1, b2), epsilon); }
@Test public void testCollection() throws Exception { String[] a1 = "test String1".split(" "); String[] a2 = "test String2".split(" "); String[] b1 = "This is my string".split(" "); String[] b2 = "That is your string".split(" "); TextSimilarityMeasure measure = new LevenshteinComparator(); assertEquals(1, measure.getSimilarity(a1, a2), epsilon); assertEquals(6, measure.getSimilarity(b1, b2), epsilon); }