Reproducing Protege reasoning results programmatically in Java

61 views
Skip to first unread message

Maxwell Neal

unread,
Feb 23, 2016, 10:03:49 PM2/23/16
to HermiT Users
Hi all,

I'm trying to use Hermit in Java to programmatically classify an ontology that contains 893 classes, 134 individuals and 4 SWRL rules. Several of the classes contain equivalent class axioms that use Class Expressions. Many of the individuals have Class Expressions as their asserted Types, including closure axioms. 

I can successfully classify the ontology using Protege 4.3 (takes about 1 minute) but I need to classify the ontology programmatically. I've been able to load in the ontology and verify it's consistent using the Hermit API, but I'm struggling to figure out how I can get the Hermit API to generate the inferred axioms that Protege produces.

I've tried adapting the MaterialiseInferrences.java code provided in the Hermit examples directory, but my program seems to get stuck on the fillOntology() call. Is there a way to perform my reasoning task without calling the OWL API? Any other suggestions/pointers on how to perform this classification with the same expediency as Protege?

Many thanks!

-Max

Ignazio Palmisano

unread,
Feb 24, 2016, 2:40:26 AM2/24/16
to HermiT Users
The example is using multiple inference generators - if you only need
a few of them, you could skip the unnecessary ones.
Or, you could use them one at a time to see which one is taking too
long, and at that point we can look into ways to improve it.
Cheers,
I.

>
> Many thanks!
>
> -Max
>
> --
> You received this message because you are subscribed to the Google Groups
> "HermiT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hermit-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Maxwell Neal

unread,
Mar 2, 2016, 6:10:41 PM3/2/16
to HermiT Users
Hi Ignazio,

Turns out that it was the InferredDisjointClassesAxiomGenerator that was causing my program to stick. If I comment out the lines that add that Generator, Hermit performs the classification in about the same amount of time as Protege.

I've been able to generate the axioms I need without using the InferredDisjointClassesAxiomGenerator. Thanks!

M

Sathyamoorthy R

unread,
Jul 30, 2019, 1:49:51 AM7/30/19
to HermiT Users
Hi, could you pleases share any example of that?

Kenny Cason

unread,
Jul 30, 2019, 9:55:10 AM7/30/19
to HermiT Users
I'm not sure I completely understand this question. Are you trying to generate axioms outside of the HermiT reasoner, using the same calls HermiT is using? If so I don't know why you would want to do that when HermiT will do it for you. Here is a partial example of that. Forgive me if I'm answering the wrong question:

public Boolean createReasoner(OWLOntology ont) {

Configuration config=new Configuration();
//Configuration.PrepareReasonerInferences prefs = new Configuration.PrepareReasonerInferences();
//config.prepareReasonerInferences = prefs;
//config.freshEntityPolicy = owlAPIConfiguration.getFreshEntityPolicy();
//config.individualNodeSetPolicy = owlAPIConfiguration.getIndividualNodeSetPolicy();
//config.individualTaskTimeout = owlAPIConfiguration.getTimeOut();
config.reasonerProgressMonitor = new HxProgressMonitor();
config.ignoreUnsupportedDatatypes = false;
config.throwInconsistentOntologyException = false;

reasoner = new Reasoner(config, ont);


    // Get a Start date/time
Date d1 = new Date();

// Set the config to inference every type available
Set<InferenceType> precompute = EnumSet.of(InferenceType.CLASS_HIERARCHY);
precompute.addAll(reasoner.getPrecomputableInferenceTypes());

// Do the actual inferencing
reasoner.precomputeInferences(precompute.toArray(new InferenceType[precompute.size()]));

//Get a Stop date/time
Date d2 = new Date();

// Compute the execution time
DecimalFormat myDecimalFormatter = new DecimalFormat("###,###.###");
System.out.println("HxReasoner.precompute: inference execution time: " +
myDecimalFormatter.format((((double) d2.getTime() - d1.getTime()) / 1000) / 60) +
" minutes");
}

Sathyamoorthy R

unread,
Jul 31, 2019, 2:22:55 AM7/31/19
to HermiT Users
I assumed the question matches my requirement

- Sathya
Reply all
Reply to author
Forward
0 new messages