Sparql Query

18 views
Skip to first unread message

mnk.ya...@gmail.com

unread,
Apr 28, 2021, 8:02:20 AM4/28/21
to TopBraid Suite Users
Suppose we have classes named c1, c2,c3,c4 and c1 has property named hasReaction, C2 has property name hasadverseReaction, C3 has property named drugReaction.
 My question is: firstly can different classes has same property name which have diffrent values.
2nd question I wanted to retrieve all classes name which has some particular reaction e.g. abscess. or all wanted to retrieve name of those classes which has abscess as value of their property(hasReaction,  hasadverseReaction, drugReaction) 
Thanks 

Irene Polikoff

unread,
Apr 28, 2021, 9:17:23 AM4/28/21
to topbrai...@googlegroups.com
The answer depends on how you are associating properties with classes. There are 3 approaches and they have different semantics and syntax:

SHACL

:C1 sh:property [ sh:path :hasReaction;
                         sh:hasValue “abscess”].

Or equivalent that is not using a blank node

:C1 sh:property :C1-hasReaction;

:C1-hasReaction a sh:PropertyShape;
sh:path :hasReaction;
                        sh:hasValue “abscess”.


OWL

:C1 rdfs:subClassOf [owl:onProperty :hasReaction;
owl:hasValue “abscess" ].

It is not customary to give the URI to OWL restriction, but instead of rdfs:subClassOf, one can also use owl:equivalentClass - depends on what they want to say.


RDFS

:hasReaction rdfs:domain :C1.

There are no local restrictions in RDFS and you could not say that it has value abscess. If abscess was a class, then you could use rdfs:range.

Can the same property have 2 different values? Yes, of course. However, with RDFS, if you say

:hasReaction rdfs:range :abscess.
:hasReaction rdfs:range :somethingElse.

It will mean that every instance that is a value of :hasReaction is BOTH, an instance of the class abscess and an instance of the class somethingElse. If you do not want to say this, then you must use owl:unionOf in the range.


If abscess was a class, then you would specify SHACL constraint and OWL restriction differently. in SHACL you use sh:class constraint or you could use sh:in and a complex path :hasReaction/^rdf:type.

In OWL you would use owl:allValuesFrom or owl:someValuesFrom restriction - depending on what you want to say.

For multiple values:

With SHACL, you could do something like:

:C1 sh:property [ sh:path :hasReaction;
                         sh:hasValue “abscess”].
:C1 sh:property [ sh:path :hasReaction;
                         sh:hasValue “somethingElse”].

With OWL, you would also specify two restrictions.

In all three cases, you are NOT saying that the class has reaction abscess. You are saying that instances of a class (if they exist) have reaction “abscess”.

You may need to consider if you really need to use classes or if you are building a controlled vocabulary of instances. Then, it becomes much simpler. You just say:

:C1 :hasReaction “abscess”. Or, most likely, you want to say that it is a resource:

:C1 :hasReaction :abscess.
:C1 :hasReaction :somethingElse.

Now that you see what triples associate a class with a property, you can formulate your SPARQL query. Keep in mind that if you are using classes and subclasses, you will probably want to retrieve in the query not only classes that have the constraints, but also their subclasses.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/0bf89e78-0e6a-4ab0-82a0-8a660e427033n%40googlegroups.com.

Monika Yadav

unread,
Apr 29, 2021, 5:58:08 AM4/29/21
to topbrai...@googlegroups.com
Thanku so much for your reply dear..

You received this message because you are subscribed to a topic in the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/topbraid-users/XAet-BzUonI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/EC0DB434-2FAF-4209-8007-48BC2BDDD27D%40topquadrant.com.


--
Regards:
Monika Yadav
Assistant Professor
M.Tech (Computer Science)


Reply all
Reply to author
Forward
0 new messages