About Query Protege

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

About Query Protege

Nazia Nishat
I want to know how to query ontology to get answer using protege
Nazia Nishat
Senior Lecturer


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

Re: About Query Protege

Michael DeBellis-2
There are several ways. One is the "DL Query" tab I think it's one of the default tabs but if you don't see it go to Window>Tabs and select it from the list of Tabs. You can use the same Description Logic language you use to define classes to do queries. Type them in the field that's labeled "Query (class expression)". So for example if you wanted all the individuals that had some child you could type "Person and hasChild some Person" Note the check boxes on the right. This query will also return classes, super classes, etc. Make sure the Individuals box is checked if you are looking for Individuals. If you aren't real familiar with the DL language the Pizza tutorial and the Manchester FHKB tutorial will give you an overview (the FHKB tutorial is a bit harder but it has some more complex examples than the Pizza one, I recommend doing them both). 

Another is to use SPARQL:    "Window>Tabs>SPARQL Query"   The implementation of SPARQL in Protege doesn't do some of the things that other implementations do so if you want a really powerful SPARQL engine you can use a different implementation but I think for basic queries it can handle those pretty well. There are lots of different SPARQL implementations and tutorials. Here is one tutorial: https://jena.apache.org/tutorials/sparql.html   

A third way is to use SQWRL:  Window>Tabs>SQWRLTab  SQWRL works exactly like SWRL except on the right hand side where in SWRL  you have some expression that asserts new info into the ontology with SQWRL on the right side of rules you have sqwrl:select(?a, ?b,...) where ?a, etc. are parameters that were bound in the left side of the rule. SQWRL is a great way to debug SWRL rules, you can see if the rules are firing and if so what values they have when they do. Each time the left side of a rule succeeds it will print out the values of the selected parameters in your SQWRL rule. SQWRL also has some great features for collecting lists but remember if you use a SQWRL expression all you can do is to print out the values, you can't put any new info into the ontology. You can get more info on SQWRL here: https://github.com/protegeproject/swrlapi/wiki/SQWRL  Also, my SWRL tutorial is here and in that tutorial I show an example of using SQWRL to debug a rule: https://www.michaeldebellis.com/post/swrl_tutorial  

BTW, there are some interesting experimental tools that DBPedia has developed to query OWL ontologies. https://wiki.dbpedia.org/apply

On Thu, Oct 24, 2019 at 9:07 AM Nazia Nishat <[hidden email]> wrote:
I want to know how to query ontology to get answer using protege
Nazia Nishat
Senior Lecturer

_______________________________________________
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