TypeTokenRatioComparator extends JCasTextSimilarityMeasureBase { @Override public double getSimilarity(JCas jcas1, JCas jcas2, Annotation coveringAnnotation1, Annotation coveringAnnotation2) throws SimilarityException { double ttr1 = getTTR(jcas1, coveringAnnotation1); double ttr2 = getTTR(jcas2, coveringAnnotation2); double distance; if (ttr1 > ttr2) { distance = ttr1 - ttr2; } else { distance = ttr2 - ttr1; } return 1.0 - distance; }  @Override double getSimilarity(JCas jcas1, JCas jcas2, Annotation coveringAnnotation1,
            Annotation coveringAnnotation2);  }
@Test public void run() throws Exception { JCasTextSimilarityMeasure comparator = new TypeTokenRatioComparator(); AnalysisEngine ae = AnalysisEngineFactory.createEngine( createEngineDescription(BreakIteratorSegmenter.class) ); JCasBuilder cb1 = new JCasBuilder(ae.newJCas()); cb1.add("The quick brown fox jumps over the lazy dog."); cb1.close(); JCasBuilder cb2 = new JCasBuilder(ae.newJCas()); cb2.add("The quick brown fox jumps over another brown fox."); cb2.close(); JCas jcas1 = cb1.getJCas(); jcas1.setDocumentLanguage("en"); JCas jcas2 = cb2.getJCas(); jcas2.setDocumentLanguage("en"); ae.process(jcas1); ae.process(jcas2); assertEquals(0.9, comparator.getSimilarity(jcas1, jcas2), epsilon); }