integraal.services.concrete.InteGraal_OMQRewriting Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brunner-integraal Show documentation
Show all versions of brunner-integraal Show documentation
InteGraal module for the BRunner project
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);
}
}