SnippetGenerator { public String getSnippet(String documentText, Set<String> queryTerms) throws IOException { ArrayList<IntSpan> positions = new ArrayList<IntSpan>(); Document document = parseAsDocument(documentText, positions); return generateSnippet(document, positions, queryTerms); }  void setStemming(boolean stemming); String highlight(String documentText, Set<String> queryTerms); String getSnippet(String documentText, Set<String> queryTerms); String buildHtmlString(Snippet best, Document document, ArrayList<IntSpan> positions); String stripTag(String tag, String input); String stripTags(String input); ArrayList<SnippetRegion> combineRegions(final ArrayList<SnippetRegion> regions); static final int width; }
@Test public void testSimpleSnippet() throws IOException { SnippetGenerator generator = new SnippetGenerator(); List<String> terms = Arrays.asList(new String[] { "some", "text" }); HashSet<String> query = new HashSet<String>(terms); String result = generator.getSnippet("This is some document text", query); assertEquals("This is <strong>some</strong> document <strong>text</strong>", result); }