Re: [External] Re: SPARQL query - single class or single subclass of many subclasses

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [External] Re: SPARQL query - single class or single subclass of many subclasses

Lorenz Buehmann
I think you still did Not get the point. You have the class already. 
What is the real use case? Do you just use protege or is it some kind of test for a more complex application?


----- Reply message -----
Von: "Lyman, Daniel [USA]" <[hidden email]>
An: "User support for WebProtege and Protege Desktop" <[hidden email]>
Betreff: [protege-user] [External] Re: SPARQL query - single class or single subclass of many subclasses
Datum: Mi., Okt. 8, 2014 20:13

Thank you Samson,

I see you point.

Thank you for the query syntax suggestion; it makes sense.

With regard to my use case, it is a bit more complicated than I had indicated.
Suppose I wanted to query for Class 3 (without siblings) and also for subclasses of Class 3. "subClassOf" gets me subclasses of Class 3. But, I also need syntax to get Class 3 as well. Hope this makes sense, but perhaps I am approaching the problem wrong.

Thanks again very much to everyone for your patience and assistance.
Dan

From: protege-user [mailto:[hidden email]] On Behalf Of Samson Tu
Sent: Wednesday, October 08, 2014 12:51 PM
To: User support for WebProtege and Protege Desktop
Subject: Re: [protege-user] [External] Re: SPARQL query - single class or single subclass of many subclasses

Hi,

I think people are wondering why you need to make a query for a class when you have the IRI for the class already. I suppose such a query would be useful when you want to check whether a particular class exists in the ontology. You can extend the previous query for classes to filter for the specific class class3:

SELECT ?s WHERE {{?s a owl:Class} UNION {?s a rdfs:Class} Filter(?s=<IRI-of-class3>)}

This query should return the IRI of class3  if it exists in the ontology.

With best regards,
Samson

On Oct 8, 2014, at 7:48 AM, Lyman, Daniel [USA] <[hidden email]<mailto:[hidden email]>> wrote:


Hi Lorenz,
Using SPARQL, how do I retrieve only Class 3 (or only Instance 2) for example from the given model?
I know that I can use the "subClassOf" or "type" predicates as follows.
if I SPARQL query the given model using the "subClassOf" predicate with { ?x rdfs:subClassOf :Class 2 .}, I'll retrieve siblings Class 3, Class 4 and Class 5.
Similarly, if I query the given model using the "type" predicate with { ?x rdf:type :Class 4 .}, I'll retrieve siblings Instance 1, Instance 2 andInstance 3.
But, for my current purposes, I don't want to retrieve all the subclasses of Class 2 (ie, siblings 3, 4 and 5) or all of the sibling Instances 1, 2 and 3.

Is there a way to retrieve, for example, just Class 3 or just Instance 2 (without siblings)?

Queries with the "subClassOf" or "type" predicates do not seem to be the correct strategy for my purposes, but I can't figure out the correct SPARQL syntax to retrieve just the individual entity Class 3, or just Instance 2, for example.

I realize that questions about SPARQL are probably better suited to another forum and greatly appreciate your time and assistance.

Thank you


From: protege-user [mailto:[hidden email]] On Behalf Of Lorenz Bühmann
Sent: Wednesday, October 08, 2014 9:48 AM
To: [hidden email]<mailto:[hidden email]>
Subject: Re: [protege-user] [External] Re: SPARQL query - single class or single subclass of many subclasses

Hello Daniel,

 the question is, what do you mean by query for 'Class 3'? What is the expected result from your point of view?

Kind regards,
Lorenz



Thank you Csongor,

I'm afraid I didn't quite understand your response.

Perhaps I really don't understand your solution, or my question wasn't stated clearly.
In case of the later, let me revise the question as follows.

Given the following RDF(/XML) model of classes and instances, for example:
Class 1
                Class 2
                                Class 3
                                Class 4
                                                Instance 1
                                                Instance 2
                                                Instance 3
                                Cass 5

What is the correct SPARQL syntax to query for only Class 3 or only Instance 2?

Thanks again very much.
Dan

From: protege-user [mailto:[hidden email]] On Behalf Of Csongor Nyulas
Sent: Monday, October 06, 2014 6:40 PM
To: [hidden email]<mailto:[hidden email]>
Subject: [External] Re: [protege-user] SPARQL query - single class or single subclass of many subclasses

Everywhere where you want to refer to a specific class/instance, you should use the URI of the class/instance .

Csongor
On 10/06/2014 06:14 PM, Lyman, Daniel [USA] wrote:
As I understand SPARQL from various tutorials, subclasses (or instances) in an RDF/OWL model can be retrieved by a query such as
{ ?x rdfs:subClassOf :y .} (or { ?x rdf:type :y .}),
for example.

This query will retrieve all the subclasses (or instances) of class (y) in my model of course.

I have not been able to find a method in any tutorial to directly retrieve only the class (y) by a query such as
{ ?x rdfs:Class :y .}
or { ?x owl:Class :y .}, for example.

I have tried these queries, which do not appear to work (no match).

The only way I am able to retrieve class (y) (as a subclass of (z) for example) seems to be by
{ ?x rdfs:subClassOf :z .}.

But this approach retrieves all other subclasses of (z) as well and I want to retrieve only (y).

Is the rdfs:Class or owl:Class query described above incorrect or actually possible to do in SPARQL?
Is another method to directly retrieve a single class (y) (or instance) available (or even possible) to do in SPARQL?

Thanks very much for your assistance
Dan Lyman








_______________________________________________

protege-user mailing list

[hidden email]<mailto:[hidden email]>

https://mailman.stanford.edu/mailman/listinfo/protege-user






_______________________________________________

protege-user mailing list

[hidden email]<mailto:[hidden email]>

https://mailman.stanford.edu/mailman/listinfo/protege-user

--

Lorenz Bühmann, MSc in Computer Science

AKSW group, University of Leipzig

Group: http://aksw.org<http://aksw.org/> - semantic web research center
_______________________________________________
protege-user mailing list
[hidden email]<mailto:[hidden email]>
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user