// Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractInformationExtractor.java
// public abstract class AbstractInformationExtractor extends AbstractLoggedComponent {
// 	protected JCas jcas;
// 
// 	public abstract List<Answer> extractAnswerCandidates(AnswerSupport as, List<String> featureLabels);
// 
// 	@Override
// 	public final void process(JCas jcas) throws AnalysisEngineProcessException {
// 		super.process(jcas);
// 		this.jcas = jcas;
// 		try {
// 			// prepare input
// 			InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
// 					jcas, InputElement.type));
// 			String questionText = input.getQuestion();
// 
// 			String answerType = AnswerTypeJCasManipulator
// 					.loadAnswerType(ViewManager
// 							.getView(jcas, ViewType.ANS_TYPE));
// 
// 			List<String> keyterms = KeytermJCasManipulator
// 					.loadKeyterms(ViewManager.getView(jcas, ViewType.KEYTERM));
// 			List<String> keyphrases = KeytermJCasManipulator
// 					.loadKeyphrases(ViewManager.getView(jcas, ViewType.KEYTERM));
// 			List<SearchResult> results = SearchJCasManipulator
// 					.loadSearchResults(ViewManager.getView(jcas, ViewType.PASSAGE));
// 
// 			AnswerSupport as = new AnswerSupport(questionText, answerType,
// 					keyterms, keyphrases, results);
// 
// 			// do task
// 			List<String> featureLabels = new LinkedList<String>();
// 			List<Answer> ansCandidates = extractAnswerCandidates(as, featureLabels);
// 
// 			// save output
// 			AnswerJCasManipulator.storeAnswers(
// 					ViewManager.getView(jcas, ViewType.IE),
// 					ansCandidates, featureLabels);
// 
// 		} catch (Exception e) {
// 			throw new AnalysisEngineProcessException(e);
// 		}
// 	}
// 
// 	protected final void log(String message) {
// 		super.log(TPLogEntry.IE, message);
// 	}
// 
// }
// 
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
// 
// 	private String questionText;
// 	private String answerType;
// 
// 	private List<String> keywords;
// 	private List<String> keyphrases;
// 
// 	private List<SearchResult> results;
// 
// 	public AnswerSupport(String questionText, String answerType,
// 			List<String> keywords, List<String> keyphrases,
// 			List<SearchResult> results) {
// 		this.questionText = questionText;
// 		this.answerType = answerType;
// 
// 		this.keywords = keywords;
// 		this.keyphrases = keyphrases;
// 
// 		this.results = results;
// 	}
// 
// 	public String getQuestionText() {
// 		return questionText;
// 	}
// 	public void setQuestionText(String questionText) {
// 		this.questionText = questionText;
// 	}
// 
// 	public String getAnswerType() {
// 		return answerType;
// 	}
// 	public void setAnswerType(String answerType) {
// 		this.answerType = answerType;
// 	}
// 
// 	public List<String> getKeywords() {
// 		return keywords;
// 	}
// 	public void setKeywords(List<String> keywords) {
// 		this.keywords = keywords;
// 	}
// 
// 	public List<String> getKeyphrases() {
// 		return keyphrases;
// 	}
// 	public void setKeyphrases(List<String> keyphrases) {
// 		this.keyphrases = keyphrases;
// 	}
// 
// 	public List<SearchResult> getResults() {
// 		return results;
// 	}
// }


import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import org.oaqa.model.SearchResult;
import org.oaqa.model.Answer;
import cz.brmlab.brmson.takepig.basephase.AbstractInformationExtractor;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport;
package cz.brmlab.brmson.blanqa.phase.ie;





/**
 * Information extractor that will do a simple fixed regex match.
 *
 * Just for testing.
 *
 * Example (for question "What prize did Watson receive?" and
 * answer "Watson received the first prize of $1 million."):
 *   - inherit: jdbc.sqlite.cse.phase
 *     name: information-extractor
 *     options: |
 *       - inherit: phases.ie.fixedregex
 *         regex: "\$[^.]*"
 */

public class FixedRegexInformationExtractor extends AbstractInformationExtractor {
	Pattern regex;

	@Override
	public void initialize(UimaContext aContext)
			throws ResourceInitializationException {
		super.initialize(aContext);

		String regexStr = (String) aContext.getConfigParameterValue("regex");
		if (regexStr != null) {
			regex = Pattern.compile(regexStr);
		} else {
			throw new IllegalArgumentException(String.format("Parameter 'regex' must be specified"));
		}
	}

// Path: src/main/java/cz/brmlab/brmson/takepig/basephase/AbstractInformationExtractor.java
// public abstract class AbstractInformationExtractor extends AbstractLoggedComponent {
// 	protected JCas jcas;
// 
// 	public abstract List<Answer> extractAnswerCandidates(AnswerSupport as, List<String> featureLabels);
// 
// 	@Override
// 	public final void process(JCas jcas) throws AnalysisEngineProcessException {
// 		super.process(jcas);
// 		this.jcas = jcas;
// 		try {
// 			// prepare input
// 			InputElement input = ((InputElement) BaseJCasHelper.getAnnotation(
// 					jcas, InputElement.type));
// 			String questionText = input.getQuestion();
// 
// 			String answerType = AnswerTypeJCasManipulator
// 					.loadAnswerType(ViewManager
// 							.getView(jcas, ViewType.ANS_TYPE));
// 
// 			List<String> keyterms = KeytermJCasManipulator
// 					.loadKeyterms(ViewManager.getView(jcas, ViewType.KEYTERM));
// 			List<String> keyphrases = KeytermJCasManipulator
// 					.loadKeyphrases(ViewManager.getView(jcas, ViewType.KEYTERM));
// 			List<SearchResult> results = SearchJCasManipulator
// 					.loadSearchResults(ViewManager.getView(jcas, ViewType.PASSAGE));
// 
// 			AnswerSupport as = new AnswerSupport(questionText, answerType,
// 					keyterms, keyphrases, results);
// 
// 			// do task
// 			List<String> featureLabels = new LinkedList<String>();
// 			List<Answer> ansCandidates = extractAnswerCandidates(as, featureLabels);
// 
// 			// save output
// 			AnswerJCasManipulator.storeAnswers(
// 					ViewManager.getView(jcas, ViewType.IE),
// 					ansCandidates, featureLabels);
// 
// 		} catch (Exception e) {
// 			throw new AnalysisEngineProcessException(e);
// 		}
// 	}
// 
// 	protected final void log(String message) {
// 		super.log(TPLogEntry.IE, message);
// 	}
// 
// }
// 
// Path: src/main/java/cz/brmlab/brmson/takepig/framework/data/AnswerSupport.java
// public class AnswerSupport {
// 
// 	private String questionText;
// 	private String answerType;
// 
// 	private List<String> keywords;
// 	private List<String> keyphrases;
// 
// 	private List<SearchResult> results;
// 
// 	public AnswerSupport(String questionText, String answerType,
// 			List<String> keywords, List<String> keyphrases,
// 			List<SearchResult> results) {
// 		this.questionText = questionText;
// 		this.answerType = answerType;
// 
// 		this.keywords = keywords;
// 		this.keyphrases = keyphrases;
// 
// 		this.results = results;
// 	}
// 
// 	public String getQuestionText() {
// 		return questionText;
// 	}
// 	public void setQuestionText(String questionText) {
// 		this.questionText = questionText;
// 	}
// 
// 	public String getAnswerType() {
// 		return answerType;
// 	}
// 	public void setAnswerType(String answerType) {
// 		this.answerType = answerType;
// 	}
// 
// 	public List<String> getKeywords() {
// 		return keywords;
// 	}
// 	public void setKeywords(List<String> keywords) {
// 		this.keywords = keywords;
// 	}
// 
// 	public List<String> getKeyphrases() {
// 		return keyphrases;
// 	}
// 	public void setKeyphrases(List<String> keyphrases) {
// 		this.keyphrases = keyphrases;
// 	}
// 
// 	public List<SearchResult> getResults() {
// 		return results;
// 	}
// }


// Path: src/main/java/cz/brmlab/brmson/blanqa/phase/ie/FixedRegexInformationExtractor.java
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import org.oaqa.model.SearchResult;
import org.oaqa.model.Answer;
import cz.brmlab.brmson.takepig.basephase.AbstractInformationExtractor;
import cz.brmlab.brmson.takepig.framework.data.AnswerSupport;

package cz.brmlab.brmson.blanqa.phase.ie;





/**
 * Information extractor that will do a simple fixed regex match.
 *
 * Just for testing.
 *
 * Example (for question "What prize did Watson receive?" and
 * answer "Watson received the first prize of $1 million."):
 *   - inherit: jdbc.sqlite.cse.phase
 *     name: information-extractor
 *     options: |
 *       - inherit: phases.ie.fixedregex
 *         regex: "\$[^.]*"
 */

public class FixedRegexInformationExtractor extends AbstractInformationExtractor {
	Pattern regex;

	@Override
	public void initialize(UimaContext aContext)
			throws ResourceInitializationException {
		super.initialize(aContext);

		String regexStr = (String) aContext.getConfigParameterValue("regex");
		if (regexStr != null) {
			regex = Pattern.compile(regexStr);
		} else {
			throw new IllegalArgumentException(String.format("Parameter 'regex' must be specified"));
		}
	}

	public List<Answer> extractAnswerCandidates(AnswerSupport as, List<String> featureLabels) {