0

I am writing a DL query parser in Java. The code gives correct output when I give a class name as input, but it returns nothing when I give query like "hasColor value Red", or "hasSugar value Dry". I am using OWLAPI.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
  • 1
    You might consider responding to requests for clarification on some of your earlier questions before asking new questions (but there's no requirement to)… Aside from that, I expect that it's because there are no individuals that have color Red, or that have sugar Dry. We won't be able to tell unless we can see your data though. Can we see your data? After all, "Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself." – Joshua Taylor Oct 15 '13 at 20:19
  • There are too many possible sources for the described problem to give a meaningful answer. Possibilities include: `hasColor` or `Red` are not declared in the ontology, or there are no instances of those classes. You need to provide some of the code you have written to disambiguate. – Ignazio Oct 15 '13 at 20:52

1 Answers1

2

Assuming that you are using this code as example.

It seems that you are using the default structural reasoner. You should enable a more complex reasoner such as HermiT for instance.

First, download and add the jar to your classpath, then replace the line 178:

OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();

by

OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory();

It should work! Look at this answer for more details on this solution, as mentioned by @Joshua in the comments.

Community
  • 1
  • 1
loopasam
  • 3,027
  • 2
  • 21
  • 22
  • @DipinAzhikodan didn't mention anything about any particular source code. Where do you see anything about "line 178"? Is it based, perhaps, on the code that was referenced [here](http://stackoverflow.com/a/14356151/1281433)? – Joshua Taylor Oct 16 '13 at 14:40
  • Yeah sorry, based on the symptoms I assumed that OP was facing this problem (seen plenty of times, as you correctly spotted - I edit the answer accordingly). – loopasam Oct 16 '13 at 17:35
  • It's a reasonable assumption, in this case. I have seen similar issues due to leaving the StructuralReasoner in the example popping up in the OWLAPI mailing list - haven't managed to find one to link here though. I'll try and add an example to the OWLAPI wiki and link that. – Ignazio Oct 16 '13 at 19:58