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

integraal.services.concrete.InteGraal_OMQRewriting 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.backward_chaining.evaluators.QueryRewriter;
import fr.boreal.backward_chaining.evaluators.RewritingOutput;
import fr.boreal.component_builder.api.IAlgorithmParameters;
import fr.boreal.component_builder.api.IInputDataScenario;
import fr.boreal.component_builder.utils.ComponentPrinter;
import integraal.services.AbstractInteGraalService;
import tools.service.CommonOps;

/**
 * OMQ Rewriting
 */
public class InteGraal_OMQRewriting extends AbstractInteGraalService {

	QueryRewriter rewriter;
	Iterable result;

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

	}

	public void prepareServiceSpecificOperations() {

		setup(CommonOps.RULE_LOADING, builder::trySetRuleBase);
		setup(CommonOps.QUERY_LOADING, builder::trySetQueryBase);
		setup(CommonOps.COMPILE_RULES, builder::tryCompileRuleset);
		setup(CommonOps.BUILD_REWRITER, this::buildRew);

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

	}

	private void buildRew() {
		rewriter = builder.buildOrGetRewriter();
	}

	private void eval() {
		result = rewriter.batchEvaluate();
	}

	@Override
	protected void postProcessingTrial() {

		ComponentPrinter.writeQueriesToLog(result);

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy