I have an ontology that contains the following classes:
"Property", "PropertyType". The "PropertyType" class has two sub classes "ReadableProperty" and "WritetableProperty".
The ontology also contains an object property "hasPropertyType" with the domain "Property" and range "PropertyType".
Is it semantically correct to create the following triples (link an individual of a class to a another class through an object property):
PREFIX exmp:<http://example.org/myontology.owl#>
INSERT DATA{
exmp:someindividual rdf:type exmp:Property, owl:NamedIndividual.
exmp:someindividual exmp:hasPropertyType exmp:WritetableProperty.
}
?
Or should I link the individual of the "Property" class to an individual of the "WritetableProperty" class, and not to the class it self?
As of http://www.w3.org/TR/owl-ref/#Property:
OWL distinguishes between two main categories of properties that an
ontology builder may want to define:
Object properties link individuals to individuals.
Datatype properties link individuals to data values.
So to answer your question: the second option is the correct one.
Don't get confused with defining the Domain and Range for object properties on the terminological level, with the actual assertion of a property.
Related
In an ontology, suppose we have a class named "function" it has two instances "func1" and "func2" and suppose that the class has a data property "d".
My first problem is: how can I create individuals corresponding to either "func1" or "func2" ?
My second problem is : In the inference, with Jena rules, I want to check if individuals created for "func1" have "d" greater than some value and if individuals created for "func2" have "d" greater than another value.
I already know how to work with classes, properties and individuals but when I got to the part having instances I got stuck.
It appears that Jena Library has no support for instances, which means that you can't use getInstance() and create individuals for that instance.
Instead of having instances func1 and func2, you can make them as subclasses for the class function. This way, you can use getOntClass() and createIndividual() or getIndividual() as usual.
I have created an ontology using Protege 5-beta-17. In my ontology I have some classes:
Mountain, Lake, Location etc...
I also have an object property:
hasLocation.
For this object property I have set the range the "Location" class, and the domain
the "Mountain" and "Lake" classes.
When I try to view the ontology using the CMap tool it shows that only the
"Mountain" "hasLocation" "Location".
The "Lake" class is presented without the "hasLocation" object property.
Did I do something wrong? Ore do I have do something else in Protege?
I found out what the problem was.
When adding a domain/range to object property in protege you have to click the following buttons and select one of your classes:
If you want to add another domain/range you simply click one of the buttons again and add another class. If you are doing it like this your telling Protege that the domain/range of your object property is an INTERSECTION of two classes. This means that the individual that will take the domains/ranges place is an INSTANCE OF BOTH CLASSES and NOT EXCLUSIVELY OF ONE OF THEM.
This was my mistake. I was adding the classes to the domain in the wrong way.
So... The correct way for adding multiple distinct domains for an object property is the following:
Simply click the domain/range button again and select the "Class expression editor" tab:
And in the "Class expression editor" type in your classes like this: "ClassA or ClassB or ClassC or ...".
In my case it was "Mountain or Lake".
After that click "ok" and thats it.
I am studying OWL and I am trying to build an Ontology using Protege.
I found an option called Equivalent To in Protege.
What is that option for please? Is it for dividing the space of instances? or is it to set the Object properties that a class can have?
Equivalent to applies to class expressions, object properties and data properties.
Equivalence in class expressions
In class expressions, equivalence means that two classes have the same individuals in any interpretation (i.e., the two classes are alternate names, or equivalent definitions, for the same set of individuals).
Equivalence in data and object properties
For object and data properties, asserting that two properties are equivalent means that their domains and ranges apply to both properties, and that every assertion using one property can be rewritten as using the other.
Example
For example, suppose I declare a hasOwner object property and an ownedBy as equivalent, then: MyCar hasOwner Me implies MyCar ownedBy Me.
Is it possible in OWL to add a property onto a single class? So far, I see properties joining a pair of classes (like defining whether or not properties are symmetric, etc.). For example, what kind of property would I use to tag whether or not an animal is a pest. If it matters, I'm using Protégé to construct the ontology.
If your question is whether or not a property can have same domain and range, then yes, it is possible.
If X is a class and p is a property, it is possible to have
p range X
p domain X
and an assertion would look like:
i type X // an instance of X
i p i // a self assertion
I'm not sure how this fits your example though: how are you modeling 'being a pest'? It looks to me like you could model this as
i type Pest
e.g., as a class assertion not a property.
In OWLAPI I have a problem with ontology imported through owl:imports statement. The problem is that instances of class and class annotations included in imported ontology are not retrieved and returned.
Lets say I have ontology Rooms and ontology Buildings.
In ontology Rooms I have then following statement which is supposed to load Buildings ontology into Rooms ontology.
<owl:Ontology rdf:about="http://example.com/rooms.xml">
<owl:imports rdf:resource="http://example.com/buildings.xml"/>
</owl:Ontology>
Then in OWLAPI I load ontology Rooms (which should automatically contain Buildings)
manager = OWLManager.createOWLOntologyManager()
roomsOntology = manager.loadOntologyFromOntologyDocument(IRI.create("http://example.com/rooms.xml"))
reasoner = Reasoner.new(roomsOntology)
factory = manager.getOWLDataFactory()
After that retrieving a class from Buildings ontology still works as expected:
buildingClass = factory.getOWLClass(IRI.create("http://example.com/buildings.xml#Building"))
When I want to get instances of class Building (definitions of these instances are included in imported Buildings ontology), then it returns nothing:
instances = buildingClass.getIndividuals(roomsOntology)
Variable 'instances' is empty now.
Same problem is with class annotations if a definition of such a class is included in Buildings ontology.
I'm able to make it work when:
I move instances definitions directly to Rooms ontology (this is not possible in production since I will have 2 separated ontologies anyway)
I use function of Reasoner class (reasoner.getInstances(buildingClass, true) returns instances from both ontologies)
I pass imported ontology to getIndividuals function instead of main (Rooms) ontology (buildingClass.getIndividuals(manager.getImports(roomsOntology)))
Workaround no. 1 is not possible to make for me (it was only for testing purposes). No. 2 and 3 do not work when I need to retrieve annotations, because there is not possible to pass multiple ontologies to OWLClass.getAnnotations function and also Reasoner has no function to get annotations.
Anyway I thought that everything should work without these workarounds since all ontologies, including imported ones, are loaded at the beginning with manager.loadOntologyFromOntologyDocument function.
The issue is that owlClass.getIndividuals(OWLOntology) does not include the imports closure. If you wish to include the imports closure, you need to use another method:
Set<OWLIndividual> getIndividuals(Set<OWLOntology> ontologies);
The set of ontologies can be any set; to use the imports closure, use
ontology.getImportsClosure()
Note that this will return, in all cases, only the individuals asserted to be long to the class. If inference is needed, you will need to use a reasoner, as you mentioned.