owlapi provides us a class merger, which allow us to load ontology from multiple files/sources and then merge them together. Now I have my ontology split into two disjoint parts, i.e., a part for TBox axioms and the other for ABox assertions. So I just use merger as the following code,
OWLOntology TBox= m.loadOntologyFromOntologyDocument(new File(("XXXXXXXX/UOBM.owl")));
OWLOntology ABox = m.loadOntologyFromOntologyDocument(new File("XXXX/test.nt"));
OWLOntologyMerger merger = new OWLOntologyMerger(m);
OWLOntology o = merger.createMergedOntology(m, null);
However, I found that only class assertions in ABox are included in the mergerd ontology o, which means all role assertions are not included. I have done a lot of attempts, and finally I solved the problem by add the type assertions of properties to my ABox file, e.g., <http://semantics.crl.ibm.com/univ-bench-dl.owl#takesCourse> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .
It's really weird since such assertions have already been included in the TBox file, and I have merged TBox and ABox with merger. So why do I have to manually add them again? Is that a design issue of owlapi? Or is there a better and more common way for me to address this problem?
P.S:
My ABox file, namely, test.nt is fairly simple, which only contains several triples, without anything else. I didn't import TBox in my ABox either, since it only includes triples.
For example, the content of original test.nt can be:
<http://semantics.crl.ibm.com/univ-bench-dl.owl#a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://semantics.crl.ibm.com/univ-bench-dl.owl#LeisureStudent> .
<http://semantics.crl.ibm.com/univ-bench-dl.owl#a> <http://semantics.crl.ibm.com/univ-bench-dl.owl#takesCourse> <http://semantics.crl.ibm.com/univ-bench-dl.owl#c0> .
The second triple cannot be recognized as an object property assertion.
While by adding another triple stating that takesCourse is an object property to test.nt, the object property can then be recognized.
However, there has already been a declaration in TBox that declares takesCourse is an object property, not anything else. So why do I have to add it to ABox again since I've already merged the TBox with my ABox?
Your abox
file must use owl:imports
to include the tbox
. Without property declarations, the abox
cannot be parsed correctly otherwise.