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:
Related
I have a homework to do for my studies that requires to use Protégé.
I am pretty new with the language OWL and with this software.
We need to create an ontology on hiking trails.
I have multiple classes like Hikers, Trails, Restaurants, Hotels, Equipements, and Places.
This last class (Places) has 2 subclasses: StartEndPoint and PicnicArea.
The class StartEndPoint correspond to the places where a trails start and end. So for my Trails class I have the axiome: (startingPoint exactly 1 Places) and (endingPoint exactly 1 Places) to symbolise that a trail starts and end at exactly one starting and ending point.
Similarly, i would like to create the axiom: each starting and ending place has at least one restaurant near this point.
To do so, i have added the axiom: "eatingPlace min 1 Restaurants" in the class StartEndPoint.
But when I run the reasoner, it says no error. I did create some instances from all classes but for the instances from the class StartEndPoint, it should say that there is no restaurant as I didn't add any property "eatingPlace" to those instances (see screenshots below).
I wanted to try if the minimum one were working well and so it should have returned me an error i guess. But I got nothing.
Is it normal ? If yes why ?
And if no, how could I resolve this ?
thanks a lot for your help
The reasoner is not finding any errors because of the Open World Assumption. You are stating that each endpoint has at least one restaurant near it, but this does not place any obligation on the ontology to list which restaurant is near to your endpoints - i.e., if you ask the reasoner if there is a restaurant near endpoint X, the reasoner will say yes; but, if you ask it to list the restaurants near endpoint X, the list might be empty because the information is not included in the ontology. This is expected behaviour for OWL ontologies.
I have a "core" ontology (core.owl) in which I import a separated online ontology (imports.owl) using Protégé, ending up with a declaration in header
<Import>https://raw.githubusercontent.com/...../imports.owl</Import>
Some classes are found both in core.owl and in imports.owl, to structure the final hierarchy. Unfortunately in both ontologies they also include annotations (such as rdfs:label) resulting in the duplication of a number of annotations in the final ontology, which is no good (for example, violates the OBO profile) and is what I'd like to solve.
Could anyone suggest methods to:
identify classes in both ontologies
remove all annotations those classes have in the core.owl ontology
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 :-)
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.
I use protege 4 to merge 2 ontology sucessful and save as Onab.owl. In this file, I don't know how to change URI of ontology by OWL API. Could you help me use OWL API to change it
Thank you very much.
You can get and set the prefix name using methods of the org.semanticweb.owlapi.util.DefaultPrefixManager class. Good luck!
Create a SetOntologyID instance with the new IRI you want and apply it to the ontology:
manager.applyChange(ontology, setOntologyID());
Then save the ontology, its IRI will have been changed.