StopwordNGramContainmentMeasure extends TextSimilarityMeasureBase { @Override public double getSimilarity(Collection<String> stringList1, Collection<String> stringList2) throws SimilarityException { Set<List<String>> ngrams1 = getNGrams(retainStopwords(stringList1)); Set<List<String>> ngrams2 = getNGrams(retainStopwords(stringList2)); Set<List<String>> commonNGrams = new HashSet<List<String>>(); commonNGrams.addAll(ngrams1); commonNGrams.retainAll(ngrams2); double norm = Math.max(ngrams1.size(), ngrams2.size()); double sim = 0.0; if (norm > 0.0) { sim = commonNGrams.size() / norm; } return sim; } StopwordNGramContainmentMeasure(int n, String stopwordList); @Override double getSimilarity(Collection<String> stringList1,
			Collection<String> stringList2); @Override String getName();  }
@Test public void run() throws Exception { List<String> doc1 = new LinkedList<String>(); List<String> doc2 = new LinkedList<String>(); doc1.add("the"); doc1.add("quick"); doc1.add("will"); doc1.add("fox"); doc1.add("be"); doc1.add("over"); doc1.add("i"); doc1.add("lazy"); doc1.add("dog"); doc2.add("the"); doc2.add("quick"); doc2.add("brown"); doc2.add("will"); doc2.add("jumps"); doc2.add("be"); doc2.add("the"); doc2.add("i"); doc2.add("this"); TextSimilarityMeasure comparator = new StopwordNGramContainmentMeasure(3, "classpath:/stopwords/stopwords-bnc-stamatatos.txt"); assertEquals(0.25, comparator.getSimilarity(doc1, doc2), epsilon); }