use of info.ephyra.answerselection.filters.Filter in project lucida by claritylab.
the class AnswerSelection method getResults.
/**
* Applies <code>Filters</code> to the <code>Results</code> from the search
* component and returns up to <code>maxResults</code> results with a score
* of at least <code>minScore</code>.
*
* @param results search results
* @param maxResults maximum number of results to be returned
* @param minScore minimum score of a result that is returned
* @return up to <code>maxResults</code> results
*/
public static Result[] getResults(Result[] results, int maxResults, float minScore) {
// apply filters
for (Filter filter : filters) {
MsgPrinter.printFilterStarted(filter, results.length);
results = filter.apply(results);
MsgPrinter.printFilterFinished(filter, results.length);
}
// get up to maxResults results with a score of at least minScore
ArrayList<Result> resultsList = new ArrayList<Result>();
for (Result result : results) {
if (maxResults == 0)
break;
if (result.getScore() >= minScore) {
resultsList.add(result);
maxResults--;
}
}
return resultsList.toArray(new Result[resultsList.size()]);
}