Re: [DIG-users] How to ask for individuals
                
                Brought to you by:
                
                    dturi
                    
                
            
            
        
        
        
    | 
      
      
      From:  <r.f...@tu...> - 2006-09-22 08:26:03
      
     | 
| 
On 22. Sep 2006, at 9:45 Uhr, Tilmann Kuhn wrote:
> Dear community,
>
> I'm new to the DIG Interface an I'm facing a problem with a query I'd
> like to use to find out individuals from a KB.
>
> Suppose I've got four konzepts X, A, B, C
>
> B is subclass of A
> and
> C is subclass of B
>
> further a role "rel" connects individuals of X with individuals of A.
>
> (I don't know the correct DIG sytax for this tells. I'm creating an
> importing (in Racer) these classes with owl so that doesn't matter for
> the rest of the question.)
>
Dear Tilmann,
you probably have to generate queries in order to iterate over  
classes because this cannot be done in DIG.
Let us discuss an example:
(in-knowledge-base test)
(implies b a)
(implies c b)
(define-primitive-role rel :domain x :range a)
(instance i x)
(instance j x)
(instance k x)
(instance a1 a)
(instance b1 b)
(instance c1 c)
(related i a1 rel)
(related j b1 rel)
(related k c1 rel)
>
> Now I wonder how I can use DIG to ask for
>
> ... all individuals of X that are associated with at least one
> individual of class exactly B
>
> ... all individuals of X that are associated with at least one
> individual of class B or any subclass of B
>
> ... all individuals of X that are associated with at least one
> individual of class B or any superclass of B
Here is a solution for your queries, respectively.
(racer-answer-query
  '(?x)
  `(and (?x x) (?x ?y rel) (?y b)
        .,(loop for (concept . nil) in (concept-children b) collect
               `(neg (?y ,concept)))))
---> (((?X J)))
(retrieve (?x) (and (?x x) (?x ?y rel) (?y b)))
---> (((?X J)) ((?X K)))
(racer-answer-query
  '(?x)
  `(and (?x x) (?x ?y rel) (?y top)
        .,(loop for (concept . nil) in (concept-children b) collect
               `(neg (?y ,concept)))))
---> (((?X I)) ((?X J)))
Best regards,
Ralf
 |