ShingleExtractor implements Iterable<Shingle> { public void setMaxShingleSize(int maxShingleSize) { this.maxShingleSize = maxShingleSize; } 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 testShingleExtractor2() { String text = "This is a test. let's see if it works, if it works or not."; ShingleExtractor shingler = new ShingleExtractor(text); shingler.setMaxShingleSize(3); Set<String> shingles = new HashSet<String>(); for (Shingle shingle : shingler) { shingles.add(shingle.getText()); } assertTrue(shingles.contains("if it works")); assertTrue(shingles.contains("works or not")); assertTrue(shingles.contains("this is a")); assertFalse(shingles.contains("test. let's")); }
@Test public void testCleaning() { String text = "NHL ICE HOCKEY-CANUCKS RW BURE SUSPENDED,FOR ONE GAME"; ShingleExtractor shingler = new ShingleExtractor(text); shingler.setMaxShingleSize(3); Set<String> shingles = new HashSet<String>(); for (Shingle shingle : shingler) { shingles.add(shingle.getText()); } assertTrue(shingles.contains("bure suspended")); assertTrue(shingles.contains("for one")); assertTrue(shingles.contains("game")); assertTrue(shingles.contains("hockey canucks")); }
@Test public void testCleaning2() { String text = "NHL ICE HOCKEY- CANUCKS RW BURE SUSPENDED,FOR ONE GAME"; ShingleExtractor shingler = new ShingleExtractor(text); shingler.setMaxShingleSize(3); Set<String> shingles = new HashSet<String>(); for (Shingle shingle : shingler) { shingles.add(shingle.getText()); } assertTrue(shingles.contains("canucks")); assertTrue(shingles.contains("bure suspended")); assertTrue(shingles.contains("for one")); assertTrue(shingles.contains("game")); assertTrue(shingles.contains("hockey canucks")); }