All Downloads are FREE. Search and download functionalities are using the official Maven repository.

integraal.services.concrete.InteGraal_QA Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package integraal.services.concrete;

import org.slf4j.LoggerFactory;

import fr.boreal.component_builder.api.IAlgorithmParameters;
import fr.boreal.component_builder.api.IInputDataScenario;
import fr.boreal.component_builder.utils.ComponentPrinter;
import fr.boreal.query_evaluation.component.QueryEvaluationOutput;
import fr.boreal.query_evaluation.component.QueryEvaluator;
import integraal.services.AbstractInteGraalService;
import tools.service.CommonOps;

/**
 * Query Answering     
 */
public class InteGraal_QA extends AbstractInteGraalService {

	QueryEvaluator evaluator;
	Iterable query_answers;

	/**
	 * @param ids input data scenario
	 * @param iap algorithm parameters
	 */
	public InteGraal_QA(IInputDataScenario ids, IAlgorithmParameters iap) {
		super(ids, iap);
		LOG = LoggerFactory.getLogger(InteGraal_QA.class);

	}

	public void prepareServiceSpecificOperations() {

		setup(CommonOps.FACTBASE_LOADING, builder::trySetFactBase);
		setup(CommonOps.QUERY_LOADING, builder::trySetQueryBase);
		setup(CommonOps.BUILD_QUERY_EVALUATOR, this::buildQA);

		operation(CommonOps.QUERY_EVALUATION, this::eval);

	}



	private void buildQA() {
		evaluator = builder.buildOrGetQueryAnsweringAlgorithm();
	}

	private void eval() {
		query_answers = evaluator.batchEvaluate();
	}

	@Override
	protected void postProcessingTrial() {

		ComponentPrinter.writeUCQAnswersCountToLog(query_answers);

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy