thanks kingsley, 

i finally got it to work to fit my needs 

with this query (data : see below)

  SELECT DISTINCT ?o
  WHERE
    {
      {
        SELECT  ?s ?o
        WHERE
          {
            ?s skos:narrower ?o .
          }
      } OPTION (TRANSITIVE, t_distinct, t_in(?s), t_out(?o), t_min (1)) .
      FILTER (?s= <http://www.turnguard.com/Music>)
    }
  LIMIT 50


file closed ... for now :)

wkr www.turnguard.com




----- Original Message -----
From: "Kingsley Idehen" <[email protected]>
To: "Jürgen Jakobitsch" <[email protected]>
Cc: [email protected]
Sent: Tuesday, February 2, 2010 4:35:19 PM
Subject: Contd: [Virtuoso-users] option transitive and skos:narrower

Jürgen Jakobitsch wrote:
> hi,
>
> i'm really having troubles figuring out how to get my option transitive right 
> for the following :
>
> - i have a couple of skos:concepts in a skos:narrower hierarchy. 
> - i have an inference graph that apparently works.
> - i have read the doc (16.2.12) but can't get my sparql query to work 
> properly (i get all sorts of results but not the one i want).
>
> i'd like to list ?p and ?o of the topmost skos:concept of that hierarchy and 
> expect all sub-elements
> (the whole skos:narrower - chain) to show up in the result with 
> skos:narrowerTransitive as ?p.
>
>
> example :
>
> 1. import (file also in attachment)
>
> <rdf:Description rdf:about="http://www.turnguard.com/Music";>
>       <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
>       <skos:prefLabel xml:lang="en">Music</skos:prefLabel>
>       <skos:narrower rdf:resource="http://www.turnguard.com/Pop"; />
> </rdf:Description>
>
> <rdf:Description rdf:about="http://www.turnguard.com/Pop";>
>       <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
>               <skos:prefLabel xml:lang="en">POP</skos:prefLabel>              
>       <skos:narrower rdf:resource="http://www.turnguard.com/TechnoPop"; />
> </rdf:Description>
>
> <rdf:Description rdf:about="http://www.turnguard.com/TechnoPop";>
>         <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
>         <skos:prefLabel xml:lang="en">TECHNOPOP</skos:prefLabel>
>         <skos:narrower rdf:resource="http://www.turnguard.com/ElectroPop"; />
> </rdf:Description>
>
> <rdf:Description rdf:about="http://www.turnguard.com/ElectroPop";>
>         <rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
>         <skos:prefLabel xml:lang="en">ELECTROPOP</skos:prefLabel>
> </rdf:Description>
>
> 2. SPARQL : define input:inference "skosruleset" SELECT * FROM <urn:mygraph> 
> WHERE { ?s ?p ?o } includes statements that
>    about skos:semanticRelation (is a superprop of skos:narrower) rdfs:labels 
> (because of skos:prefLabel)
>    and skos:narrowerTransitive (is a superprop of skos:narrower)
>    - the proplem is that there's allways only ONE skos:narrowerTransitive for 
> each narrower (they go parallel)
>      which is not surprising due to the absence of any option transitive - 
> but just to make sure basic inferencing works.
>
>
> now how can i transform my sparql-query to get the following result (short 
> forms of the uris):
>
> Music skos:prefLabel "Music"
> Music rdf:type skos:Concept
> Music skos:narrower Pop
> Music skos:narrowerTransitive Pop
> Music skos:narrowerTransitive TechnoPop
> Music skos:narrowerTransitive ElectroPop
>
>
> any help or pointer to the right direction really appreciated
>
> wkr www.turnguard.com
>
>
>   
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Virtuoso-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users
>   
Here is a closer example:

# Find entities that are subcategories of Protestant Churches,
# no deeper than 3 levels within the concept scheme hierarchy filtered 
by a specific subcategory
# Demonstrates use of Inference Rule Context. sub-queries, and FILTER to 
obtain entities
# associated with category:Protestant_churches
# combined with the use of the transitivity option that sets a 3-step 
traversal down the hierarchy


DEFINE input:inference "skos-trans"          
PREFIX p: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX geo: <http://www.georss.org/georss/>

SELECT distinct ?m ?n ?p ?dist ?trans
WHERE {
        {
            SELECT ?c  ?m ?n ?p ?trans?dist
            WHERE {
                      ?m rdfs:label ?n.
                      ?m skos:subject ?c.
                      ?c skos:broaderTransitive 
category:Protestant_churches .
                      ?c skos:broaderTransitive ?trans OPTION 
(TRANSITIVE, t_distinct, t_in (?c), t_out (?trans), t_max (3),  t_step ( 
'step_no' ) as ?dist) .
                      ?m p:abstract ?d.
                      ?m geo:point ?p
              FILTER ( lang(?n) = "fr" )
              FILTER ( lang(?d) = "fr" )
                  }
        }
FILTER (?trans = <http://dbpedia.org/resource/Category:Churches_in_Paris>)
    }
ORDER BY ASC (?dist)



-- 

Regards,

Kingsley Idehen       
President & CEO 
OpenLink Software     
Web: http://www.openlinksw.com
Weblog: http://www.openlinksw.com/blog/~kidehen
Twitter: kidehen 






-- 
punkt. netServices
______________________________
Jürgen Jakobitsch
Codeography

Lerchenfelder Gürtel 43 Top 5/2
A - 1160 Wien
Tel.: 01 / 897 41 22 - 29
Fax: 01 / 897 41 22 - 22

netServices http://www.punkt.at


Reply via email to