use of org.opensolaris.opengrok.analysis.CompatibleAnalyser in project OpenGrok by OpenGrok.
the class SearchHelper method prepareSummary.
/**
* Prepare the fields to support printing a full blown summary. Does nothing
* if {@link #redirect} or {@link #errorMsg} have a none-{@code null} value.
*
* <p>
* Parameters which should be populated/set at this time: <ul>
* <li>{@link #query}</li> <li>{@link #builder}</li> </ul> Populates/sets:
* Otherwise the following fields are set (includes {@code null}): <ul>
* <li>{@link #sourceContext}</li> <li>{@link #summarizer}</li>
* <li>{@link #historyContext}</li> </ul>
*
* @return this instance.
*/
public SearchHelper prepareSummary() {
if (redirect != null || errorMsg != null) {
return this;
}
try {
sourceContext = new Context(query, builder.getQueries());
summarizer = new Summarizer(query, new CompatibleAnalyser());
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Summarizer: {0}", e.getMessage());
}
try {
historyContext = new HistoryContext(query);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "HistoryContext: {0}", e.getMessage());
}
return this;
}
use of org.opensolaris.opengrok.analysis.CompatibleAnalyser in project OpenGrok by OpenGrok.
the class SummarizerTest method bug15858.
/**
* If the last token in a text fragment is a token we're searching for,
* and that token is also present earlier in the fragment, getSummary()
* used to throw a StringIndexOutOfBoundsException. Bug #15858.
*/
@Test
public void bug15858() throws Exception {
Query query = new QueryBuilder().setFreetext("beta").build();
Summarizer instance = new Summarizer(query, new CompatibleAnalyser());
// This call used to result in a StringIndexOutOfBoundsException
assertNotNull(instance.getSummary("alpha beta gamma delta beta"));
}
Aggregations