OWL-XML serialization of SWRL rules with OWLAPI - owl

Where is the OWL-XML serialization format specified which is used by the OWLAPI to serialize SWRL rules?
E.g. by serializing a simple rule using Protege (which uses the OWLAPI as far as I know) I get the following code:
<DLSafeRule>...
<ClassAtom>
<Class IRI="#Person"/>
<Variable IRI="x"/>
</ClassAtom>
</DLSafeRule>
This is different from the SWRL specification [1]:
<swrlx:classAtom>
<owlx:Class owlx:name="Person" />
<ruleml:var>x1</ruleml:var>
</swrlx:classAtom>
and from the suggestion introduced in [2]:
<owl:ClassAtom>
<owl:Class IRI="#Person"/>
<owl:IndividuialVariable IRI="#x"/>
</owl:ClassAtom>
Thank you!
[1]https://www.w3.org/Submission/SWRL/
[2]http://dl.acm.org/citation.cfm?id=2890050

As far as I can tell the document you're after is this one:
https://www.w3.org/TR/owl-xmlsyntax/
Note that OWL/XML and RDF/XML are very different serialization formats. RDF/XML is a W3C standard, while OWL/XML is not.
Edit: The following paper is by Matthew Horridge, one of the main authors of the OWL API and of the current Protege code base, and points to a W3C recommendation I was not aware of.
http://ontogenesis.knowledgeblog.org/88
https://www.w3.org/TR/2009/REC-owl2-xml-serialization-20091027/
There is no SWRL mention in that document, so technically there is no spec for SWRL output in OWL/XML. But the note in the appendix https://www.w3.org/TR/2009/REC-owl2-xml-serialization-20091027/#Appendix:_The_Derivation_from_the_Functional_Syntax_.28Informative.29
describes how the the tags were designed; so it makes sense to go with AKSW's theory about the functional syntax tags simply translated the same way.

Related

Add imports in OWLAPI

I'd like to check the consistency of a number of triples by using a reasoner.
There are around 700k triples to check, so for each of them I created a file with the triple and the direct types of its subject and object.
My problem is that if I don't import all the properties everytime I load one of the small file, all ObjectProperty statements are treated as AnnotationAxioms, which doesn't allow to spot any inconsistency.
How can I import all the properties just once and add them to the file with the triples everytime I load one?
Thanks in advance!
Edit
I add here an example of the small files I am analysing.
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:wdt="http://www.wikidata.org/prop/direct/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="http://www.wikidata.org/entity/Q295376">
<rdf:type rdf:resource="http://www.wikidata.org/entity/Q5"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.wikidata.org/entity/Q21077119">
<rdf:type rdf:resource="http://www.wikidata.org/entity/Q17299750"/>
<wdt:P1346 rdf:resource="http://www.wikidata.org/entity/Q295376"/>
<rdf:type rdf:resource="http://www.wikidata.org/entity/Q4993329"/>
</rdf:Description>
</rdf:RDF>
The above lines do not include the import axioms.
Thanks!
It will be much faster to not write the triple to disk. Create tee ontology with declarations for the properties and then add the axiom you wish to test. You can then create the reasoner, test for consistency, discard the reasoner and remove the axiom you just tested. The ontology is then available to be used with another axiom and a new reasoner.
However, you're checking each axiom in isolation; while the axioms might be consistent on their own, this does not provide assurances as to what the axioms will do together - assuming that they will appear in the same ontology after you finish your test.
Specifically on how to add an import to an ontology, see the OWLAPI documentation at https://github.com/owlcs/owlapi/wiki/Add-an-import-directive-to-an-ontology
I don't believe that's the best solution to your scenario, but it's the question you asked :-)

get concepts of a loaded ontology using OWL API

I try to get all 'subclass-of' axioms of an ontology. I tried by using the following statement.
System.out.println(MyOntology.getAxioms(AxiomType.SUBCLASS_OF));
Effectively, it returns the ontology 'subclass-of' axioms, except for the first 'subclass-of' axiom which links OWL:Thing with my first ontology class.
I cannot understand why this link isn't taken into account in that case ?
Is there any way to get all 'subclass-of' axioms including those linking OWL:Thing with other classes ?
Here you can find the ontology screenshot and the issue description:

SWRL : ^ not work on protege 4.3

I'm trying to add a SWRL rule to protege using conjuction sign ^ but Protege 4.3 does not approve that sign.
This issue is also present for swrl buildins such as swrlb:lessThanOrEqual.
What's wrong with ^? May I use , instead?
The terms in the Protege SWRL editor are separated by commas, not ^. See, for instance, the screenshots in my answer to SWRL rules in protege 3.4.8.
whats wrong with ^ ? may i use , instead ?
That the answer, yes. I'm not sure what prevented you from trying it in your own running Protege, though.

Protege reasoners cannot infer inverse property

I have a simple ontology with a class "Person" that has 3 individuals 'A','B','C'. They are related each other by an object property named isFatherOf, for example,
A isFatherOf B
B isFatherOf C
and I set another property hasFather, which is an Inverse property of isFaterOf. I expected the reasoner infer:
B hasFatherOf A
C hasFatherOf B
However, None of the built-in reasoner (FaCT++, HermiT, Pellet) didn't infer them.
Plus, I want to make a property chain of isFatherOf, say isGrandFatherOf:
A isGrandFatherOf C
Therfore, I set the SuperProperty like below:
isFatherOf o isFatherOf SubPropertyOf isGrandFatherOf
but it also fails.
I have the same results on Protege 4.3 and 5.0.0 (Build RC1) with HermiT 1.3.8, Pellet 2.2.0 and FaCT++ 1.6.4. I've searched docs and questions on the internet, but still can't figure out why it is happening. Here is the link for the owl file.
Possible Bug Report Added
The problem might be caused from a bug. I had the desired inference results in the environment of: Win7 64-bit, Protege 5-beta21 (and Protege 5-RC1), java 1.8.0_20.
But the problem did occur in the environment of: Win10 64-bit, Protege 5-beta21 (and Protege 5-RC1), java 1.8.0_73. I couldn't get any inference results. I've tried the inference with 3 different reasoners (HermiT 1.3.8, Pellet 2.2.0 and FaCT++ 1.6.4). Among them, only HermiT 1.3.8 shows the error message below. The log says win8 but it's actually win10.

Loading different files using OWL API

I am using OWL API to load different files and merge into one for reasoning. I have one file describing the ontology and several files with individuals. Every individual has foaf properties, e.g., foaf:title, when I print the axioms it shows
'AnnotationAssertion(http://xmlns.com/foaf/0.1/title...'
and reasoning does not work. If I add
<'owl:DatatypeProperty rdf:about="http://xmlns.com/foaf/0.1/title'/>
into the individual file than title loads as
'DataPropertyAssertion(http://xmlns.com/foaf/0.1/title...' and reasoning works.
In the FOAF ontology is says that it is a data property, but loading it did not work either. I am using OWLOntologyMerger to merge the ontologies.
And I cannot add that into every file. Is there a way to do it programmatically or any way?
Thanks.
Use owl:imports from each file to import the base ontology, or foaf.
The problem here is that the owl api needs the declaration to be available either in the file or in the imported ontologies. It is not possible to parse rdf/XML unambiguously otherwise.

Resources