ShingleExtractor implements Iterable<Shingle> { private void addText(String text) { if (text == null || text.isEmpty()) return; List<Sentence> sentences = ss.splitPos(text); for (Sentence sentence : sentences) { String currSentence = sentence.getText(); int startSentence = sentence.getStart(); List<Token> tokens = ts.tokenizePos(currSentence); List<Token> cleanTokens = new LinkedList<Token>(); for (Token t : tokens) { t.setStart(t.getStart() + startSentence); t.setEnd(t.getEnd() + startSentence); String token = text.substring(t.getStart(), t.getEnd()); String cleanToken = sm.clean(token); if (cleanToken.isEmpty()) continue; t.setText(cleanToken); cleanTokens.add(t); } cleanedSentences.add(cleanTokens); } } private  ShingleExtractor();  ShingleExtractor(Article a);  ShingleExtractor(String text); void process(String text); int getMaxShingleSize(); @Override Iterator<Shingle> iterator(); void setMaxShingleSize(int maxShingleSize);  }
@Test public void testAddText() throws Exception { String text = null; ShingleExtractor shingler = new ShingleExtractor(text); Iterator<Shingle> it = shingler.iterator(); assertFalse(it.hasNext()); shingler = new ShingleExtractor(""); it = shingler.iterator(); assertFalse(it.hasNext()); }