Skip to content

Commit

Permalink
Set software architecture for probabilistic reasoners
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseta committed Jun 21, 2016
1 parent 879efc6 commit f1049b8
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory;
import com.google.common.collect.Sets;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;
import org.dllearner.core.AbstractClassExpressionLearningProblem;
import org.dllearner.core.AbstractLearningProblem;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.EvaluatedDescription;
import org.dllearner.core.LearningProblemUnsupportedException;
Expand All @@ -32,15 +30,13 @@
import org.dllearner.core.probabilistic.unife.AbstractParameterLearningAlgorithm;
import org.dllearner.exceptions.UnsupportedLearnedAxiom;
import org.dllearner.utils.unife.ReflectionHelper;
import org.dllearner.utilities.Helper;
import org.dllearner.utils.unife.OWLUtils;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.AxiomType;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLAnnotation;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassAxiom;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
Expand All @@ -56,7 +52,8 @@
import unife.bundle.utilities.BundleUtilities;

/**
*
* There could be different version of LEAP (sequential, multi-thread, distributed),
* so we need an abstract class.
* @author Giuseppe Cota <giuseppe.cota@unife.it>, Riccardo Zese
* <riccardo.zese@unife.it>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
import java.util.Set;
import org.apache.log4j.Logger;
import org.dllearner.core.AbstractComponent;
import org.dllearner.core.ComponentInitException;
import org.dllearner.core.KnowledgeSource;
import unife.bundle.logging.BundleLoggerFactory;
import org.dllearner.reasoning.unife.ProbabilisticReasonerType;
import org.dllearner.utils.unife.OWLUtils;
import org.semanticweb.owlapi.model.OWLOntology;
import org.springframework.beans.factory.annotation.Autowired;

/**
*
Expand All @@ -29,6 +33,8 @@ public abstract class AbstractProbabilisticReasonerComponent extends AbstractCom
* The underlying knowledge sources.
*/
protected Set<KnowledgeSource> sources;

private OWLOntology ontology;

public AbstractProbabilisticReasonerComponent() {

Expand All @@ -46,6 +52,11 @@ public AbstractProbabilisticReasonerComponent(Set<KnowledgeSource> sources) {
public AbstractProbabilisticReasonerComponent(KnowledgeSource source) {
this(Collections.singleton(source));
}


public void init() throws ComponentInitException {
ontology = OWLUtils.mergeOntologies(sources);
}

/**
* Gets the knowledge sources used by this reasoner.
Expand All @@ -56,10 +67,12 @@ public Set<KnowledgeSource> getSources() {
return sources;
}

@Autowired
public void setSources(Set<KnowledgeSource> sources) {
this.sources = sources;
}

@Autowired
public void setSources(KnowledgeSource... sources) {
this.sources = new HashSet<KnowledgeSource>(Arrays.asList(sources));
}
Expand All @@ -82,4 +95,11 @@ public void changeSources(Set<KnowledgeSource> sources) {
* @return The probabilistic reasoner type.
*/
public abstract ProbabilisticReasonerType getReasonerType();

/**
* @return the ontology
*/
public OWLOntology getOntology() {
return ontology;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import org.dllearner.core.ComponentInitException;
import org.dllearner.reasoning.unife.ProbabilisticReasonerType;
import org.semanticweb.owlapi.model.OWLAxiom;

/**
*
* @author Giuseppe Cota <giuseppe.cota@unife.it>, Riccardo Zese
* <riccardo.zese@unife.it>
*/
public class BUNDLEWrapper extends AbstractProbabilisticReasonerComponent{
public class BUNDLEWrapper extends AbstractProbabilisticReasonerComponent implements OWLProbabilisticExplanationReasoner {

@Override
public ProbabilisticReasonerType getReasonerType() {
Expand All @@ -23,6 +24,13 @@ public ProbabilisticReasonerType getReasonerType() {

@Override
public void init() throws ComponentInitException {
super.init();
initialized = true;

}

@Override
public OWLProbExplanationReasonerResult computeQuery(OWLAxiom axiom) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.dllearner.core.probabilistic.unife;

import java.util.Set;
import org.semanticweb.owlapi.model.OWLAxiom;

/**
*
* @author Giuseppe Cota <giuseppe.cota@unife.it>
*/
public class OWLProbExplanationReasonerResult extends OWLProbReasonerResult {

private Set<Set<OWLAxiom>> explanations;

public OWLProbExplanationReasonerResult(OWLAxiom axiom, Double probability, Set<Set<OWLAxiom>> explanations) {
super(axiom, probability);
this.explanations = explanations;
}

/**
* @return the explanations
*/
public Set<Set<OWLAxiom>> getExplanations() {
return explanations;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.dllearner.core.probabilistic.unife;

import org.semanticweb.owlapi.model.OWLAxiom;

/**
*
* @author Giuseppe Cota <giuseppe.cota@unife.it>
*/
public class OWLProbReasonerResult {

private OWLAxiom axiom;

private Double probability;

public OWLProbReasonerResult(OWLAxiom axiom, Double probability) {
this.axiom = axiom;
this.probability = probability;
}

/**
* @return the axiom
*/
public OWLAxiom getAxiom() {
return axiom;
}

/**
* @return the probability
*/
public Double getProbability() {
return probability;
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.dllearner.core.probabilistic.unife;

import org.semanticweb.owlapi.model.OWLAxiom;

/**
* This marker interface for those probabilistic reasoner that returns the
* set of explanations as well.
*
* @author Giuseppe Cota <giuseppe.cota@unife.it>
*/
public interface OWLProbabilisticExplanationReasoner extends ProbabilisticReasoner {

public OWLProbExplanationReasonerResult computeQuery(OWLAxiom axiom);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.dllearner.core.probabilistic.unife;

import org.semanticweb.owlapi.model.OWLAxiom;

/**
*
* @author Giuseppe Cota <giuseppe.cota@unife.it>
*/
public interface OWLProbabilisticReasoner extends ProbabilisticReasoner {

public OWLProbReasonerResult computeQuery(OWLAxiom axiom);

}

0 comments on commit f1049b8

Please sign in to comment.