AvgCharactersPerTokenMeasure extends JCasTextSimilarityMeasureBase { @Override public double getSimilarity(JCas jcas1, JCas jcas2, Annotation coveringAnnotation1, Annotation coveringAnnotation2) throws SimilarityException { List<Token> t1 = JCasUtil.selectCovered(jcas1, Token.class, coveringAnnotation1); List<Token> t2 = JCasUtil.selectCovered(jcas2, Token.class, coveringAnnotation2); int noOfCharacters = 0; for (Token token : t1) { noOfCharacters += token.getCoveredText().length(); } for (Token token : t2) { noOfCharacters += token.getCoveredText().length(); } return (double) noOfCharacters / (t1.size() + t2.size()); }  @Override double getSimilarity(JCas jcas1, JCas jcas2,
    		Annotation coveringAnnotation1, Annotation coveringAnnotation2);  }
@Test public void run() throws Exception { JCasTextSimilarityMeasure comparator = new AvgCharactersPerTokenMeasure(); AnalysisEngine ae = AnalysisEngineFactory.createEngine(BreakIteratorSegmenter.class); JCasBuilder cb = new JCasBuilder(ae.newJCas()); cb.add("one", Token.class); cb.add("two", Token.class); cb.add("three", Token.class); cb.add("four", Token.class); cb.close(); assertEquals(3.75, comparator.getSimilarity(cb.getJCas(), cb.getJCas()), epsilon); }