Example - SmartDataAnalytics/DL-Learner GitHub Wiki

General structure

The general procedure is to define the core components of the DL-Learner stepwise like

// set up the knowledge base
AbstractKnowledgeSource source = ...;
source.init();
		
// set up the reasoner
AbstractReasonerComponent reasoner = ...;
reasoner.init();
		
// set up the learning problem
AbstractLearningProblem lp = ...;
lp.init();
		
// set up the learning algorithm
AbstractCELA la = ...;
la.init();
	
// start the algorithm
la.start();

// get class expression having a confidence score above a threshold of 0.8
List<? extends EvaluatedDescription> currentlyBestEvaluatedDescriptions = la.getCurrentlyBestEvaluatedDescriptions(0.8);

How to learn an OWL class expression

Generating a set of class expressions that describe the instances of a given class could for example be done as follows:

// load an ontology (from file) based on OWL API
String ontologyPath = "/PATH/TO/ONTOLOGY";
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
OWLOntology ontology = man.loadOntologyFromOntologyDocument(new File(ontologyPath));

// set up the knowledge base
AbstractKnowledgeSource source = new OWLAPIOntology(ontology);
source.init();
		
// set up the reasoner
AbstractReasonerComponent reasoner = new OWLAPIReasoner(source);
reasoner.init();
		
// create a learning problem and set the class to describe
ClassLearningProblem lp = new ClassLearningProblem(reasoner);
lp.setClassToDescribe(IRI.create("http://SOME/CLASS/IRI"));
lp.init();
		
// create the learning algorithm
// we use CELOE here, which is an refinement operator based algorithm
AbstractCELA la = new CELOE(lp, reasoner);
la.init();
	
// start the algorithm
la.start();

// get class expression having a confidence score above a threshold of 0.8
List<? extends EvaluatedDescription> currentlyBestEvaluatedDescriptions = la.getCurrentlyBestEvaluatedDescriptions(0.8);