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

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.

Related

How to retrieve anonymous subclass from OWL in SPARQL

I am unsure of the SPARQL query needed to replicate the results of DL Query "has part some benzamide".
That query should return all entities that have some part that is a benzamide or a subclass of benzamide.
My SPARQL attempt:
PREFIX opioid: <https://mac389.github.io/ontology#>
SELECT ?substance ?substance_label
{ ?substance rdfs:subClassOf* opioid:chemical_entity.
?substance rdfs:subClassOf* / opioid:has_part / owl:someValuesFrom opioid:benzamide.
?substance rdfs:label ?substance_label }
Link to OWL as RDF/XML
In this code the 1st and 3rd lines work as intended, retrieving a list of all chemical entities and their labels. When I add the second line, the query returns no answers (there should be 21 items which is what the DL Query in Protege returns).
How does one query for anonymous subclasses like this?
I have looked at this question but I am looking for a subclass that only fulfills one of the property restrictions. I don't fully understand the answer to this question, but mine seems very related.

Topology query in geosparql

I have inspired this articles and created an ontology with using geosparql ontology. Two classes named Area and Park were created as subclasses of the Feature class of geosparql. 3 Area instances and 1 Park instance were added to the ontology. Then, geometry instances were created (asWKT) as a subclass of Polygon class of geosparql. And the geometry instances were related with the Park and Area instances via hasGeometry object property (The created ontology and instances).
I have tried to make a topology query to find out which Area instances are within the Park instance. So, I have run the below query with using the sparql query plugin of Protégé 4.3.
PREFIX geosparql: http://www.opengis.net/ont/geosparql#
PREFIX su: http://www.example.org/su#
SELECT ?x ?y
WHERE {
?x a su:Area ;
geosparql:hasGeometry ?xgeo .
?y a su:Park ;
geosparql:hasGeometry ?ygeo .
?xgeo geosparql:sfWithin ?ygeo .
}
No results return but I know that there are two Area instances within the Park instance. I did not find out the problem. Do not I query topological relations with using geosparql and protégé?
The problem is you don't import the "good" use of sfWithin entity.
There is a difference between
http://www.opengis.net/ont/geosparql#sfWithin and http://www.opengis.net/def/function/geosparql/sfWithin.
Actually, I don't understand yet how to proceed in Protégé with this statement, I'm sorry about that.
If you really need to use such a topology query, you can use GraphDB instead, which implements a good working plugin for GeoSPARQL.

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 the Triples for OWL Symmetric or Inverse object property is populated?

Whether the Graph DB dataload engine creates additional Triples for the inserted Triples which have OWL Symmetric or Inverse object property in the RDFS model?
Let’s assume the model and individuals given below,
RDFS model:
I have the classes Male and Female, and an object property “hasMarried” with domain as Male and Range as Female. The characteristic of “hasMarried” is set as “Symmetric”.
Triples:
:Male1 rdf:type :Male
:Female1 rdf:type :Female
:Male1 :hasMarried :Female1
Question here is while Inserting the above Triples in Ontotext, would it generate additional triple as follows based on the Model definition for the “Symmetric” object property,
:Female1 :hasMarried :Male1
If the above is not happening, would SPARQL query answer for the following query by inferencing the “Symmetric” object property in the referenced RDFS model?
Select ?s ?o
WHERE {
:Female1 :hasMarried ?o
}
Expected answer:
:Female1 :Male1
Yes this is what you are going to get. Note that you will need the owl horst optimized ruleset when creating the repository(the rdfs ruleset will not be enough).
To the first question: Yes, :Female1 :hasMarried :Male1 would follow.
To the second question: The WHERE clause of your SPARQL query does not contain ?s.
For the SPARQL Query Select ?s ?o WHERE { ?s :hasMarried ?o } with enabled reasoning you should get two answers (:Female1, :Male1) and (:Male1, :Female1)
Two remarks:
RDFS does not support "symmetric properties", you'll need OWL for example.
Defining domain and range as you did will also entail the following two triples:
:Male1 rdf:type :Female . :Female1 rdf:type :Male
In general it doesn't make much sense to define two different (and possibly disjoint!) properties as domain and range of a symmetric property.

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

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.