
fr.boreal.component_builder.components.QueryAnsweringComponentBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integraal-component Show documentation
Show all versions of integraal-component Show documentation
Components for the main functionalities of InteGraal
package fr.boreal.component_builder.components;
import java.util.Collection;
import java.util.Objects;
import fr.boreal.model.kb.api.FactBase;
import fr.boreal.model.query.api.Query;
import fr.boreal.query_evaluation.component.CountingQueryEvaluator;
import fr.boreal.query_evaluation.component.QueryEvaluator;
import fr.lirmm.boreal.util.externalHaltingConditions.ExternalAlgorithmHaltingConditions;
/**
* A builder class for preparing and creating components for query answering
* over fact bases. This class provides methods for setting up query evaluators
* with optional external halting conditions.
*/
public class QueryAnsweringComponentBuilder {
/**
* Prepares and returns a {@link QueryEvaluator} for answering the given set of
* queries over the provided fact base, with optional external halting
* conditions to limit non-terminating algorithms.
*
* @param queries a collection of {@link Query} objects to be
* evaluated over the fact base. This must not
* be {@code null}.
* @param factbase the {@link FactBase} that serves as the data
* source for answering the queries. This must
* not be {@code null}.
* @param externalHaltingConditions optional conditions used to limit the
* evaluation process, such as timeouts or
* maximum number of states. If {@code null},
* no external halting conditions are applied.
* @return a {@link QueryEvaluator} configured to answer the given queries over
* the fact base with optional halting conditions.
* @throws NullPointerException if either {@code queries} or {@code factbase} is
* {@code null}.
*/
public static QueryEvaluator prepareAndGetQueryAnsweringFrom(Collection queries, FactBase factbase,
ExternalAlgorithmHaltingConditions externalHaltingConditions) {
Objects.requireNonNull(queries, "query must not be null");
Objects.requireNonNull(factbase, "factBase must not be null");
return new QueryEvaluator(queries, factbase, null, true, externalHaltingConditions);
}
/**
* Prepares and returns a {@link CountingQueryEvaluator} for answering the given
* set of queries over the provided fact base, with optional external halting
* conditions to limit non-terminating algorithms. The
* {@link CountingQueryEvaluator} counts the number of answers in addition to
* performing the query evaluation.
*
* @param queries a collection of {@link Query} objects to be
* evaluated over the fact base. This must not
* be {@code null}.
* @param factbase the {@link FactBase} that serves as the data
* source for answering the queries. This must
* not be {@code null}.
* @param externalHaltingConditions optional conditions used to limit the
* evaluation process, such as timeouts or
* maximum number of states. If {@code null},
* no external halting conditions are applied.
* @return a {@link CountingQueryEvaluator} configured to answer the given
* queries over the fact base with optional halting conditions and
* counting the number of answers.
* @throws NullPointerException if either {@code queries} or {@code factbase} is
* {@code null}.
*/
public static CountingQueryEvaluator prepareAndGetCountingQueryAnsweringFrom(Collection queries,
FactBase factbase, ExternalAlgorithmHaltingConditions externalHaltingConditions) {
Objects.requireNonNull(queries, "query must not be null");
Objects.requireNonNull(factbase, "factBase must not be null");
return new CountingQueryEvaluator(queries, factbase, null, true, externalHaltingConditions);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy