owl_api.binding.OWLAPIExplanatorBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brunner-owlAPI Show documentation
Show all versions of brunner-owlAPI Show documentation
OWLAPI module for the BRunner project
The newest version!
package owl_api.binding;
import java.util.Set;
import org.semanticweb.owl.explanation.api.ConsoleExplanationProgressMonitor;
import org.semanticweb.owl.explanation.api.ExplanationProgressMonitor;
import org.semanticweb.owl.explanation.api.NullExplanationProgressMonitor;
import org.semanticweb.owl.explanation.impl.blackbox.AllInOneExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.BlackBoxExplanationGenerator2;
import org.semanticweb.owl.explanation.impl.blackbox.ContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.DivideAndConquerContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.DynamicSlidingWindowContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.EntailmentCheckerFactory;
import org.semanticweb.owl.explanation.impl.blackbox.ExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.InconsistentOntologyClashExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.InconsistentOntologyContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.InconsistentOntologyExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.InitialEntailmentCheckStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.ModularityContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.OrderedAxiomWithWindowContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.OrderedDivideAndConquerStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.SimpleContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.SimpleExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.SlidingWindowContractionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.StructuralExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.StructuralTypePriorityExpansionStrategy;
import org.semanticweb.owl.explanation.impl.blackbox.checker.ConsistencyEntailmentCheckerFactory;
import org.semanticweb.owl.explanation.impl.blackbox.checker.PatternBasedConsistencyEntailmentCheckerFactory;
import org.semanticweb.owl.explanation.impl.blackbox.checker.SatisfiabilityEntailmentCheckerFactory;
import org.semanticweb.owl.explanation.impl.laconic.LaconicExplanationGenerator;
import org.semanticweb.owlapi.model.OWLAxiom;
import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory;
public class OWLAPIExplanatorBuilder {
private OWLAPIAlgorithmParameterConfig config;
private Set axioms;
private PelletReasonerFactory reasonerFactory;
public OWLAPIExplanatorBuilder(OWLAPIAlgorithmParameterConfig config,Set axioms,
com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory reasonerFactory) {
this.config = config;
this.axioms=axioms;
this.reasonerFactory=reasonerFactory;
}
/**
* @return the explanator for the axioms and the input reasoner to use
*/
public BlackBoxExplanationGenerator2 build() {
/*
* Default configuration
*/
EntailmentCheckerFactory checkerFactory = new SatisfiabilityEntailmentCheckerFactory(reasonerFactory);
ExpansionStrategy expansionStrategy = new StructuralTypePriorityExpansionStrategy(InitialEntailmentCheckStrategy.PERFORM);
ContractionStrategy contractionStrategy = new DivideAndConquerContractionStrategy();
ExplanationProgressMonitor progressMonitor = new NullExplanationProgressMonitor();
if (config.checkerFactory().isPresent()) {
checkerFactory = switch (config.checkerFactory().get()) {
case CONSISTENCY_ENTAILMENT_CHECKER_FACTORY -> new ConsistencyEntailmentCheckerFactory(reasonerFactory, 0);
case PATTERN_BASED_CONSISTENCY_ENTAILMENT_CHECKER_FACTORY -> new PatternBasedConsistencyEntailmentCheckerFactory(reasonerFactory, 0);
case SATISFIABILITY_ENTAILMENT_CHECKER_FACTORY ->
new SatisfiabilityEntailmentCheckerFactory(reasonerFactory);
};
}
if (config.expansionStrategy().isPresent()) {
expansionStrategy = switch (config.expansionStrategy().get()) {
case ALL_IN_ONE_EXPANSION_STRATEGY -> new AllInOneExpansionStrategy();
case INCONSISTENT_ONTOLOGY_CLASH_EXPANSION_STRATEGY -> new InconsistentOntologyClashExpansionStrategy();
case INCONSISTENT_ONTOLOGY_EXPANSION_STRATEGY -> new InconsistentOntologyExpansionStrategy();
case SIMPLE_EXPANSION_STRATEGY -> new SimpleExpansionStrategy<>();
case STRUCTURAL_EXPANSION_STRATEGY -> new StructuralExpansionStrategy();
case STRUCTURAL_TYPE_PRIORITY_EXPANSION_STRATEGY -> new StructuralTypePriorityExpansionStrategy(InitialEntailmentCheckStrategy.PERFORM);
};
}
if (config.contractionStrategy().isPresent()) {
contractionStrategy = switch (config.contractionStrategy().get()) {
case DIVIDE_AND_CONQUER_CONTRACTION_STRATEGY -> new DivideAndConquerContractionStrategy();
case DYNAMIC_SLIDING_WINDOW_CONTRACTION_STRATEGY -> new DynamicSlidingWindowContractionStrategy();
case INCONSISTENT_ONTOLOGY_CONTRACTION_STRATEGY -> new InconsistentOntologyContractionStrategy();
case MODULARITY_CONTRACTION_STRATEGY -> new ModularityContractionStrategy();
case ORDERED_AXIOM_WITH_WINDOW_CONTRACTION_STRATEGY -> new OrderedAxiomWithWindowContractionStrategy();
case ORDERED_DIVIDE_AND_CONQUER_STRATEGY -> new OrderedDivideAndConquerStrategy();
case SIMPLE_CONTRACTION_STRATEGY -> new SimpleContractionStrategy();
case SLIDING_WINDOW_CONTRACTION_STRATEGY -> new SlidingWindowContractionStrategy();
};
}
if (config.progressMonitor().isPresent()) {
progressMonitor = switch (config.progressMonitor().get()) {
case CONSOLE_EXPLANATION_PROGRESS_MONITOR -> new ConsoleExplanationProgressMonitor<>();
case LACONIC_EXPLANATION_GENERATOR -> new LaconicExplanationGenerator<>(axioms, null, null);
case NULL_EXPLANATION_PROGRESS_MONITOR -> new NullExplanationProgressMonitor();
};
}
BlackBoxExplanationGenerator2 generator = new BlackBoxExplanationGenerator2(axioms,
checkerFactory, expansionStrategy, contractionStrategy, progressMonitor);
return generator;
}
}