Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] Ontology query

Thomas Russ tar at ISI.EDU
Fri Jan 29 10:25:33 PST 2010

On Jan 29, 2010, at 7:26 AM, Wouter Theetaert wrote:

> Dear all,
> I have an ontology which looks like this:
> - Classes: 'Person', 'Location'
> - Properties: 'hasLocation'
> - Individuals: 'Wouter' (of class Person), 'Kitchen' (of class  
> Location).
> Using the latest version of the OWL API (v3), it's no problem to add  
> 'Wouter hasLocation Kitchen' to the ontology. Indeed, when I look at  
> the ontology with Protege afterwards, 'hasLocation Kitchen' is added  
> to the Individual 'Wouter'.
> I would like to get around the other way, now. Given the Individual  
> Wouter, I want to know its location. This is in fact some kind of  
> query, but after spending hours on Google, I still didn't find out  
> how to do that. This are the queries I want to execute:
> - Given the Individual Wouter, what is its location? ('Wouter  
> hasLocation Kitchen' is added to the ontology, so I want the  
> Individual 'Kitchen' as a response).

This is a bit indirect, but you can use the API functions to build a  
query like that.

    1.  Use OWLIndividual.getObjectPropertyValues to get a Map of  
ObjectPropertyExpression to Sets of individuals
    2.  Use the ObjectProperty object for "hasLocation" as the key  
into this map.  The resulting set are the fillers

or it also looks like you could use a reasoner

    1.  Create a reasoner
    2.  Use OWLReasoner.getRelatedIndividuals  (actually its on  

> - What are the Individuals that are located in the Kitchen? (the  
> response should be 'Wouter', in this case).

This is a bit trickier to do through the API unless you define an  
inverse property.  The SQWRL solution is a bit nicer.

   It really looks like you would have to go through all of the  
property axioms to find those with the right property and value.  If  
you need this, then creating an inverse property would make sense.   
You may be able to create one programmatically and use it with the  
reasoner, but I haven't tried this.

More information about the protege-owl mailing list