Sub-group and Super-group (Class/Subclass) relation in OWL - schema

I need some help regarding OWL syntax. I have a synthetic population class called 'Person'. Person contains population information, and PersonWithinAdminRegion is another class represents subgroup of person class. For example 'Person' class contains information about all persons in the USA. FloridaPerson or MiamiPerson can be an example of PersonWithinAdminRegion. Basically, PersonWithinAdminRegion is a subgroup of supergroup Person. It not sub-class because sub-class inherits properties of super-class and add some more. It is not the case in my situation. My question is how to show sub-group of a super-group in OWL syntax?
Person a owl:Class.
PersonWithinAdminRegion ? ?

There is no inheritance in OWL. Therefore no properties are inherited by subclasses. The subclass hierarchy is a type of subsumption hierarchy with only one semantic: a member of a subclass is a member of the (super) class. An example:
:Person a owl:Class .
:PersonWithinAdminRegion a owl:Class .
:PersonWithinAdminRegion rdfs:subClassOf :Person .
:FloridaPerson a :PersonWithinAdminRegion .
From this, one can infer:
:FloridaPerson a :Person .
And that is all. No other properties or values will be inferred. E.g. RDFS and OWL semantics are more like set theory (classification) than object-oriented class definition.
So it seems the above will get you the semantics that you want. If you wanted to go deeper into the subsumption hierarchy, let's say:
:PersonInFloridaRegion rdfs:subClassOf :PersonWithinAdminRegion .
:p1 a :PersonInFloridaRegion .
...then you will be able to infer:
:p1 a :PersonWithinAdminRegion .
:p1 a :Person .
...and so on.

Even though I am still not sure of your modelling perspective, and whether there are some properties that Person has, but PersonWithinAdminRegion, doesn't. Here is an idea for solution.
You can create a generic class Person, and a subclass of it USAPerson, then a PersonWithinAdminRegion, which is a subclass of Persons as well and a sibling of PersonWithinAdminRegion. Thus:
Both USAPerosn and PersonWithinAdminRegion are Person;
Persons will include USAPersons, so when make a subset of Person you can still have the control over USAPerosn;
PersonWithinAdminRegion can still not have properties that USAPerson have.
Person a owl:Class
USAPerson a owl:Class
PersonWithinAdminRegion a owl:Class
USAPerson rdfs:subClassOf Peron
PersonWithinAdminRegion rdfs:subClassOf Peron
Hope this helps.

Related

SPARQL Query that retrieves individuals of a subclass that owned by another individual of a class in Protégé?

I started using Protégé as required by my job and currently learning how to use SPARQL Query for it.
I got a question in my mind as following:
Let's say that I have an ontology as this:
👇owl:think
👇 Fruit
- Apples
- Bananas
-Owner
Now, I have an individual for the subclass "Apples" and let's name it "GreenApple". Also for the subclass "Bananas" and called "SweetyBanana".
I have many individuals for the class "Owner", but let's name one of them through a data property "hasName" as "Jimmy".
The individual which hasName of "Jimmy" has a relationship through an object property called "hasFruit" and it links him to the "GreenApple" and to the "SweetyBanana" individuals as following:
{ Individual (which is named "Jimmy" by the hasName property) hasFruit GreenApple }.
{ Individual (which is named "Jimmy" by the hasName property) hasFruit SweetyBanana }.
Now my question is that if I want to do SPARQL Query that retrieves the Fruits that owned by the individual "Jimmy" and belong to the "Apples" subclass. What would be the right structure of such query. I tried many but non is working perfectly.
I tried this but no hope:
?ID :hasName "Jimmy"^^xsd:string .
?ID rdf:subClassOf :Fruit .
?ID rdf:subClassOf ?FruitList .
?FruitList :hasFruit ?JimmyFruit .
Also tried this, but no hope too:
?ID :hasName "Jimmy"^^xsd:string .
?ID rdf:subClassOf :Apples .
?ID rdf:subClassOf ?AppleFruit .
?AppleFruit :hasFruit ?JimmyFruit .
So simply that I just want the query to show me the fruit that owned by Jimmy which is under the subclass of Apples. I don't want to see the Bananas individuals, nor that fruits which are owned by other owners.
Remmber:
hasName is a Data Proprty.
hasFriut is an Object Property.
Apples is a subclass of the class Fruit.
Bananas is a subclass of the class Fruit.
Owner is a class .
"Jimmy" is a value.
GreenApple is an individual that in the Apples subclass.
SweetyBanana is an individual that in the Bananas subclass.
You would need something like:
SELECT *
WHERE {
?id :hasName "Jimmy" ;
:hasFruit ?fruit .
?fruit rdf:type/rdfs:subClassOf* :Apples }
Now, it doesn't matter if :Apples is a subclass of :Fruit, as you are only interested in apples anyway.
In response to your comment, we can use a property path:
?fruit rdf:type/rdfs:subClassOf* :Apples
means that ?fruit is either an instance of :Apples, or an instance of a (direct or indirect) subclass of :Apples.

SPARQL code missing individuals from classes that are not subclasses

I am currently working on a sparql query that computes every individual and the class that the individual exists in. Here is an (awful) example of what my ontology looks like:
Owl:Thing
-Lion
-Elephant
-Pets
-Dog
-Cat
Where Lion and Elephant are classes with no subclasses and Dog and Cat are subclasses of the class Pet. When I run my code, I got the individuals from Dog and Cat, but no individuals from Lion or Elephant.
SELECT ?indiv ?class
WHERE {
?class rdf:type owl:Class .
?indiv rdf:type owl:NamedIndividual .
?indiv rdf:type ?class
} ORDER BY ?class ?indiv
So basically, the result of my code are the individuals that come from only classes that are subclasses, when I am expecting to have the individuals from all classes. Could anyone please help?

How to make property of property in Protégé?

I have a following problem to model in OWL using Protégé:
Multiple Songs could be performed in different Performances. Each Song could be arranged by different Arranger in different Performance.
I already know how to relate a Song to a Performance using object property. Now, how to map a Song-Performance pair to an Arranger? (In relational database, I would call this as a "descriptive attribute" of a many-to-many Song-Performance relationship).
I know that I could use an annotation to an object property, but I would like to be able to infer something from this property. (For example: what Song has an Arranger arranged, and in which Performance?) As far as I know, I am not able to do inference from an annotation.
It's not necessary to add properties of properties to model this scenario, although a property is an object (a uri) and therefore can include any property, not just annotation properties. rdfs:subPropertyOf is a good example. Statement reification isn't necessary either. It's a matter of creating an object that holds information about the song and performance.
Here is a model that represents an Arranger's relationship to a Song-Performance:
ex:SongPerformance a owl:Class .
ex:Arranger a owl:Class .
ex:arranged rdfs:domain ex:Arranger ;
rdfs:range ex:SongPerformance .
ex:songPerformed rdfs:domain ex:SongPerformance ;
rdfs:range ex:Arranger .
ex:performedIn rdfs:domain ex:SongPerformance ;
rdfs:range ex:Arranger .
Given this list, an example instance is:
ex:Arranger-1 ex:arranged ex:SP1 .
ex:SP1 ex:performedIn ex:Performance_1 ;
ex:songPerformed ex:Song1 .
Then you can find which songs has an arranger arranged in a given performance through the following SPARQl query:
SELECT ?arranger ?song ?performance
WHERE {
?arranger a ex:Arranger ;
ex:arranged ?sp .
?sp ex:songPerformed ?song ;
ex:performedIn ?performance .
}

how to generate triples by using sparql entailment rules in DotnetRDF?

I defined some classes in RDF file, and subclasses inherited from it by using protege as following:
Person class.
employee subclass of person.
ex-employee subclass of employee.
for example if I have ex-employee instances I want to generate and insert them as instances for employee class.
also if I have employee instances I want to insert them as instances of Person class.
what I am asking for is how to generate triples based on inheritance relationship between these classes as following statement ?
Insert Into myGraphFile
{?newInstance rdf:type ?y}
FROM myGraphFile
WHERE {
?newInstance rdf:type ?x.
?x rdfs:subClassOf ?y.
}
how can I do this by using DotnetRDF?
Also I appreciate any example which illustrates entailment rules in sparql with dotnetRDF library.

OWL inferencing question

I am using the Jena semantic web framework version 2.6.3. I have code that creates a model with owl inferencing and then adds the following triples:
_:bnode-3 rdf:type owl:Restriction .
_:bnode-3 owl:onProperty :offspringOf .
_:bnode-3 owl:someValuesFrom :Person .
_:bnode-3 rdfs:subClassOf :Person .
_:bnode-3 is supposed to be a restriction class which, for example, would contain :joe if :bob is a :Person and the following triple were asserted:
:joe :offspringOf :bob .
Then, since the restriction class is a subclass of Person, :joe would also be a person.
And, in fact, this works. What's confusing to me is that after I assert just the 4 triples at the top of this post, the inferencer creates a blank node which is a Person. In other words, the following triple is now in the model:
_:b0 rdf:type :Person
I don't understand why it would do this. Any help in understanding this would be greatly appreciated.
Thanks.
Kent.
I am not sure why the inferencer would do this as I am not an OWL expert - have you tried asking your question on the jena-users lists?
They will usually answer you pretty promptly and they should know why you get the observed behaviour.
Note
I reformatted your question as your code samples were somewhat confusing - please don't write out Triples as [ex:subject ex:predicate ex:object] since it looks rather like some syntactic sugar in Turtle/N3/SPARQL which would result in additional Blank Nodes being created beyond just those you intended