PatternExtract { public boolean contains(final String documentText, final String... needles) { final String text = getCoveredText(documentText); return Arrays.stream(needles).anyMatch(text::contains); } PatternExtract(final Entity from, final Entity to, final int start, final int end); Entity getFrom(); Entity getTo(); int getStart(); int getEnd(); void setWordTokens(final List<WordToken> words); List<WordToken> getWordTokens(); boolean contains(final String documentText, final String... needles); String getCoveredText(final String documentText); String getText(); boolean isEmpty();  }
@Test public void testContains() { pe.setWordTokens(Collections.singletonList(token)); Assert.assertTrue(pe.contains("this is sample text", "is")); Assert.assertFalse(pe.contains("this is sample text", "text")); Assert.assertTrue(pe.contains("this is sample text", "text", "this")); }