Skip to content

Example

LorenzBuehmann edited this page Dec 3, 2014 · 2 revisions

How to learn a class expression

// 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(new OWLClassImpl(IRI.create("http://ns.softwiki.de/req/CustomerRequirement")));
lp.init();
		
// create the learning 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);

Clone this wiki locally