Querying in SnapSPARQL

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Querying in SnapSPARQL

Sharon
Can you help me figure out how to query in SnapSPARQL for the following cases?  I am using Protege 5.2.0 desktop on a Mac.  I have figured out how to query for individual relationships, but struggling with classes.  Or will querying only work for individual values? Let's say I have the following classes:

- Person with individual Mary
- Organization with subclasses Academic, Professional, and Sports
- ProductsForSale with subclasses Books, SportsEquipment, and Shirts

Mary belongsTo Sports
Sports sells SportsEquipment

1.  How do I query what organization Mary belongs to?
2. How do I query what products the Sports organization sells?
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Lorenz Buehmann
It's plain SPARQL what you have to use here...and you can query any RDF
data as long as you're able to write the corresponding triple patterns.

The predicate for subclass relation is rdfs:subClassOf, for instanceOf
it's rdf:type

The triple is

:Mary rdf:type :Person

thus, the triple pattern is

:Mary rdf:type ?types


The rest is up to you, as said, it's standard SPARQL

On 21.07.2018 22:09, [hidden email] wrote:

> Can you help me figure out how to query in SnapSPARQL for the following cases?  I am using Protege 5.2.0 desktop on a Mac.  I have figured out how to query for individual relationships, but struggling with classes.  Or will querying only work for individual values? Let's say I have the following classes:
>
> - Person with individual Mary
> - Organization with subclasses Academic, Professional, and Sports
> - ProductsForSale with subclasses Books, SportsEquipment, and Shirts
>
> Mary belongsTo Sports
> Sports sells SportsEquipment
>
> 1.  How do I query what organization Mary belongs to?
> 2. How do I query what products the Sports organization sells?
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Sharon
Thank you.  In SPARQL the object properties relationships appear, but not in
SnapSPARQL.  I would still like to know how to make it work in SnapSPARQL if
anyone knows that.

In SPARQL, how would I write the query such that I get the results where
Mary shows up in a column for ?Person; Sports shows up for ?Organization?



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

samsontu
Hi,

On Jul 22, 2018, at 10:12 AM, Sharon <[hidden email]> wrote:

In SPARQL, how would I write the query such that I get the results where
Mary shows up in a column for ?Person; Sports shows up for ?Organization?

The query depends entirely on how you model the “belongsTo" relationship between Mary (an individual) and Sports (a class). You can save your ontology in Turtle syntax (.ttl) and see the pattern of triples that you need to write for the query.

With best regards,
Samson


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Sharon
Thank you.  I saved in Turtle.  What am I looking for?  In Protege it looks
the same in TTL as well as RDF/XML but I may be missing something.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

samsontu
Look at the saved file in a text editor to see how OWL axioms are represented in SPARQL-like syntax.

With best regards,
Samson


On Jul 22, 2018, at 2:11 PM, Sharon <[hidden email]> wrote:

Thank you.  I saved in Turtle.  What am I looking for?  In Protege it looks
the same in TTL as well as RDF/XML but I may be missing something.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Sharon
If I see this, how do I write the query?

:Mary rdf:type owl:NamedIndividual ,
:Person ,
[rdf:type owl:Restriction ; owl:onProperty :belongsTo ; owl:someValuesFrom
:Sports ]



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Lorenz Buehmann
Just replace what you're querying for by a variable - yes, it's as
simple as this - no magic behind SPARQL. Just triple patterns reusing
Turtle syntax of RDF to match RDF triples.


On 23.07.2018 00:19, Sharon wrote:

> If I see this, how do I write the query?
>
> :Mary rdf:type owl:NamedIndividual ,
> :Person ,
> [rdf:type owl:Restriction ; owl:onProperty :belongsTo ; owl:someValuesFrom
> :Sports ]
>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Sharon
I am sorry, but I still do not understand. Going back to my original message:

Classes:

- Person with individual Mary
- Organization with subclasses Academic, Professional, and Sports
- ProductsForSale with subclasses Books, SportsEquipment, and Shirts

Mary belongsTo Sports
Sports sells SportsEquipment

And in Turtle I see this for Mary belongsTo Sports:

:Mary rdf:type owl:NamedIndividual ,
 :Person ,
 [rdf:type owl:Restriction ; owl:onProperty :belongsTo ; owl:someValuesFrom
 :Sports ]

1.  How do I query what organization Mary belongs to? With a column for
Organization to get only result as Sports.
2. How do I query what products the Sports organization sells? With a column
for Products and the result as SportsEquipment.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Lorenz Buehmann
And I said, replace the entity that you're asking for by a variable and
select this one...


prefix ...
select ?x where {

:Mary rdf:type
 [rdf:type owl:Restriction ; owl:onProperty :belongsTo ; owl:someValuesFrom
 ?x ]

}

don't forget to add the correct prefix delcarations

On 24.07.2018 01:55, Sharon wrote:

> I am sorry, but I still do not understand. Going back to my original message:
>
> Classes:
>
> - Person with individual Mary
> - Organization with subclasses Academic, Professional, and Sports
> - ProductsForSale with subclasses Books, SportsEquipment, and Shirts
>
> Mary belongsTo Sports
> Sports sells SportsEquipment
>
> And in Turtle I see this for Mary belongsTo Sports:
>
> :Mary rdf:type owl:NamedIndividual ,
>  :Person ,
>  [rdf:type owl:Restriction ; owl:onProperty :belongsTo ; owl:someValuesFrom
>  :Sports ]
>
> 1.  How do I query what organization Mary belongs to? With a column for
> Organization to get only result as Sports.
> 2. How do I query what products the Sports organization sells? With a column
> for Products and the result as SportsEquipment.
>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Sharon
That worked.  
1. How can I make the same question work in SnapSPARQL because it did not
work there?

2.  If I had the following for SPARQL:
- Person (class) with individuals Mary, Bob, Joe
-Organization (class) with subclasses Academic, Professional, and Sports
----Sports subclass with individual LALakers

Mary belongsTo Sports (the subclass)
Bob belongsTo LALakers (the individual)

How can I define a query to show ?Person ?Organization and then enter Mary
and have the Organization response be the subclass, but then enter Bob and
have the Organization answer be the individual LALakers?



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Querying in SnapSPARQL

Lorenz Buehmann


On 29.07.2018 19:58, Sharon wrote:
> That worked.  
> 1. How can I make the same question work in SnapSPARQL because it did not
> work there?
That should work. It's basically SPARQL + some reasoning. Provide sample
data + query to reproduce a possible bug.

>
> 2.  If I had the following for SPARQL:
> - Person (class) with individuals Mary, Bob, Joe
> -Organization (class) with subclasses Academic, Professional, and Sports
> ----Sports subclass with individual LALakers
>
> Mary belongsTo Sports (the subclass)
> Bob belongsTo LALakers (the individual)
>
> How can I define a query to show ?Person ?Organization and then enter Mary
> and have the Organization response be the subclass, but then enter Bob and
> have the Organization answer be the individual LALakers?
please draw the RDF graph on a sheet of paper. Then you will see that
both things follow a different path. On the one hand, you want the (most
specific) class Mary belongs to and on the other hand you want an
instance of the general class organization. If you don't know this in
advance, how should this be possible via a generic query?

You could try property paths of SPARQL 1.1 or UNION if you know that
these are both cases only.

>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user


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