owl how to (if possible ) annotate an owl:class - sparql

I used to annotate a predicate like the following:
<rdf:Description rdf:about="http://music.org/musicontology/mo#fromEra">
<rs:hasSimilarityValue rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.1</rs:hasSimilarityValue>
</rdf:Description>
where fromEra is a predicate and has a property called hasSimilarityValue which its value is 0.1
I would like to do the same for some classes, I dont' know if that is possible in owl or not, I supposed that is possible because when looking for the owl generated from my protege i can see the followings:
<!-- http://music.org/musicontology/mo#JoyfulFeeling -->
<owl:Class rdf:about="http://music.org/musicontology/mo#JoyfulFeeling">
<rdfs:subClassOf rdf:resource="http://music.org/musicontology/mo#Feeling"/>
</owl:Class>
so it sounds that it is possible to do that.
Just to make my question clear, I would like to end up with something like this:
JoyfulFeeling is a class that has a property called hasSimilarityValue, which its range is double

In general there is no problem having properties associated with a class. If the property is of type owl:AnnotationProperty, then reasoners will ignore it, if running a reasoner is a concern at all.

Related

Regions of adjacent line portions with the same dataproperties in Protégé 5

I try to process line-based data using protege 5 and picture similar "regions" of a curve.
So I have a curve, which is deconstructed into portions of equal lengths in my ontology (class Portion, instances p_1, ... ,p_n). The portions are defined by their start- and endpoints (point_1, ... ,point_n+1), furthermore, the radius of the curve is stored in the ontology as data property of the instances (p_1, ... ,p_n). I managed to reason the adjacency relations between the different portions
hasStartPoint(p_2,point_2) o isEndpointOf(point_2,p_1) => isNextOf(p_2, p_1)
hasEndPoint(p_1,point_2) o isStartpointOf(point_2,p_2) => hasNext(p_1, p_2)
I also managed to create defined classes, storing portions with the same radius.
So here is my question: I want to reason the sets of portions (regions), which are adjecent and share the same curve radius. Then, i instances of a class Set should be created, for i different radius and non-adjecent sets, individuals (region1, ... ,regioni).
Here is the exemplary data I want to process: data I want to process
In other words: if a radius appears twice on the given line, and the portions of this radius are not adjacent, they should not be part of the same region. Further, regions should be created automatically when adding portions of different radius. The only idea I have, is to somehow traverse the set of portions with a loop over the isNext triplet, which requires some coding I guess, but I can't find anything alike here...
I hope, my problem is clear and I am happy to read if anybody has an idea on it.
Thank you in advance
Julian
From the owl-api tag, I infer you're looking to write code that uses the OWL API to reach your objective (You didn't mention which reasoner you're using in Protege - you'll need to use the same reasoner in your code to get things like hasNext relations inferred).
In OWL API, I'd do something like the following:
Infer the hasNext triples, if they are not already stored in the ontology file
For each of the defined classes that separate instances with the same radius
Retrieve all individuals of that class
Retrieve all property assertions with hasNext
Aggregate these instances into regions - e.g., seed one region for each property assertion, then merge two regions if their instances all belong to the same defined class and an endpoint in one region is a startpoint in the other. Repeat until only one region is left for a defined class (I believe, from your problem description, that regions cannot span outside of instances with the same radius) or until no further merges can happen.
In terms of OWLAPI implementation, once you have the ontology loaded in an OWLOntology object, you'd create an OWLReasoner with the OWLReasonerFactory implementation available for the reasoner of your choice (examples of this exist in the OWLAPI wiki), then there are a number of methods that can come in handy:
(Referencing OWLAPI 4 here because that's what Protege uses)
Get all individuals of a class: OWLOntology::getClassAssertionAxioms(OWLClassExpression) gives all axioms stating an individual belongs to a class, useful to retrieve instances of your defined classes. Through OWLReasoner, you can use OWLReasoner::getInstances(OWLClass)
Get all object property assertions for an individual: OWLOntology::getObjectPropertyAssertionAxioms(OWLIndividual). Useful to get hasNext values. Through the reasoner, this would be OWLReasoner::getObjectPropertyValues(OWLNamedIndividual, OWLObjectPropertyExpression)
I believe the rest of the algorithm can be implemented without OWLAPI specific code.

Is dcterms:identifier an inverse functional property?

To me, the dcterms:identifier property seems like a legitimate inverse functional property. When two things share the same identifier, I think it is safe to conclude that it is the same thing.
Is there any compelling reason not to define it as such (owl:InverseFunctionalProperty) in my ontology?
If you need to stay in OWL 2 DL, then it's not a good idea to declare data properties to be inverse functional - only object properties can be declared as such without violating the constraints and end up in OWL 2 FULL.
dcterms:identifier has a range of rdfs:Literal defined here
You could use a HasKey axiom to achieve similar results: keys were introduced in OWL 2 for the purpose of identifying one or more properties whose values are identifiers for the referring individuals, and both object and data properties can be used.

How to declare a custom class relation in OWL2

My apologies if my question is too basic, but after some time looking for an answer, I had nowhere to go but here.
Suppose the following classes in an ontology (expressed in an OWL 2 file):
<owl:Class rdf:ID="ClasseOne">
</owl:Class>
<owl:Class rdf:ID="ClasseTwo">
</owl:Class>
What I have is 1000 instances of ClassOne and 5000 instances of ClassTwo. In my reality all the ClassOne instances are related in the very same way (let's say the relationship is named "isRelatedTo") to all the instances of ClassTwo.
My idea was to declare a class relation and use it in the declaration of ClassOne, instead of having an ObjectProperty that should have its value declared in each ClassOne instance.
How to accomplish that?
Thanks in advance!
Classes are not related by properties in OWL except for subsumption/equivalence. Usually, individuals of a class A are related to individuals of a class B by a property p, e.g. A(a1), B(b1), p(a1, b1) states that an individual a1 of class A is related by p to an individual b1 of class B.
You could express something like any individual of A has a relationship p to an individual of B by using a subclass axiom with an OWL class expression as super class, e.g.
Class: A
SubClassOf: p some B
(in Manchester OWL Syntax here)
Note, that this doesn't necessary mean the other way around, i.e. the direction matters.

redefine and declare property in RDFS

I want to create a RDFS schema about venue info which contains for example:
address info.
I find another schema about it:https://schema.org/Place which has the property address info.
The first question is can I declare the Venue also has the property of address?
I already know that I can use the property without declaring it. The reason I want to declare it to make my schema more clear.
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:place="https://schema.org/Place#"
xml:base="http://localhost:3000/VenueSchema#">
<rdfs:Class rdf:ID="Venue">
<rdfs:subClassOf rdf:resource="https://schema.org/Place"/>
</rdfs:Class>
<rdf:Property rdf:ID="address">
<rdf:type source:"https://schema.org/Place#address">
</rdf:Property>
</rdf:RDF>
The second question is can I redefine the property address? Can it achieve override or overload effects?
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:place="https://schema.org/Place#"
xml:base="http://localhost:3000/VenueSchema#">
<rdfs:Class rdf:ID="Venue">
<rdfs:subClassOf rdf:resource="https://schema.org/Place"/>
</rdfs:Class>
<rdf:Property rdf:ID="address">
<rdfs:domain rdf:resource= "#Venue">
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>
</rdf:Property>
</rdf:RDF>
The first question is can I declare the Venue also has the property of
address? I already know that I can use the property without declaring
it. The reason I want to declare it to make my schema more clear.
Classes don't have properties in RDFS. Properties can have declared domains and ranges, but that doesn't make properties belong to classes. When you say that
p rdfs:domain D
you're saying that when x p y, you can infer that x rdf:type D. That's all the domain axiom does. The range axiom is similar, but lets you infer a type for y. You can declare additional domains and ranges on a property, but be aware that that means that you'll be able to infer that with that property belong to all the domains. E.g., if you say that:
hasFoot rdfs:domain Elephant
and
hasFoot rdfs:domain Human
then when you see that Jimbo hasFoot foot73, you're going to be able to infer that Jimbo is a Human and an Elephant.
The second question is can I redefine the property address? Can it
achieve override or overload effects?
You can say additional things about resources; that's one of the wonderful things about the Semantic Web. However, you can't make anyone else retract what they've said about, though you're free to ignore what they've said. That is, you can include declarations of a property even if someone else has already declared them. The RDF data model is based on a set of triples, and triples don't include duplicates, so there's no difference whether you say something once or a hundred times.
It doesn't make sense to talk about overriding or overloading, though. I've said it before in the answers to some of your earlier questions, but RDF is not an object oriented programming language, even though it has a notion of properties and classes. A property is just an IRI. It doesn't have any behavior or side effects. You can say additional things about a property, and you ignore things that others have said about them, but there's sense in which you can override or overload a property.
You can define subproperties, which might be useful. E.g., you can say:
:hasParent a rdfs:Property ;
rdfs:range :Human .
:hasMother a rdfs:Property ;
rdfs:range :Woman ;
rdfs:subPropertyOf :hasParent .
If you do this, then when you say x hasMother y, you can infer that y is a Woman and a Human, and you can infer that x hasParent y.

OWLAPI not returning annotations and instances

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.