package info.ephyra.answerselection;

import info.ephyra.answerselection.filters.Filter;
import info.ephyra.io.MsgPrinter;
import info.ephyra.search.Result;

import java.util.ArrayList;

/**
 * <p>The <code>AnswerSelection</code> component applies <code>Filters</code> to
 * <code>Results</code> to promote promising results, to drop results that are
 * unlikely to answer the question and to derive additional results from the raw
 * results returned by the <code>Searchers</code>.</p>
 * 
 * @author Nico Schlaefer
 * @version 2006-06-28
 */
public class AnswerSelection {
	/**
	 * The <code>Filters</code> that are applied to the <code>Results</code>.
	 * Filters are applied in the order in which they appear in this list.
	 */
	private static ArrayList<Filter> filters = new ArrayList<Filter>();
	
	/**
	 * Registers a <code>Filter</code>. Filters are applied in the order in
	 * which they are registered.
	 * 
	 * @param filter <code>Filter</code> to add
	 */
	public static void addFilter(Filter filter) {
		filters.add(filter);
	}
	
	/**
	 * Unregisters all <code>Filters</code>.
	 */
	public static void clearFilters() {
		filters.clear();
	}
	
	/**
	 * 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
                int maxdisplay=0;
                int currentfilter=0;
		for (Filter filter : filters) {

                        currentfilter++;
			if(currentfilter==10)
				for(int i=0;i<results.length;i++){
					if(results[i].getSentence()!=null&&maxdisplay<10 && results[i].getAnswer()!=null){
						System.out.println("\nAnswer: " + resuls[i].getAnswer());
						System.out.println("Snippet: " + results[i].getSentence() + "\nScore: " + results[i].getScore());
						maxdisplay++;
					}
					maxdisplay=0;
				}                        


		       	//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()]);
	}
}

@@ -2089,16 +2089,17 @@
  + resul
+t
 s%5Bi%5D.get
@@ -2245,24 +2245,26 @@
 %09%09%09%09%7D%0D%0A%09%09%09%09%09
+//
 maxdisplay=0

Update AnswerSelection.java