Re: How to add "labels" to SPARQL output

Learned something new! Thanks. 

Il 10 Novembre 2016 07:09:41 CET, Fabian Cretton <Fabian.Cretton@hevs.ch> ha scritto:
>Hi Mario,
>
>CONSTRUCT is not what you want here as CONSTRUCT is used to get back a
>graph.
>
>If I understand correctly, what you want is to assign a value to a
>?inOutLabel variable, and BIND can be used to do that:
>SELECT  ?node_related ?inOutLabel 
>WHERE {
>
>    ?central_node a <node> ;
>        <id> 123 .
>    {
>        [] <output_node_link> ?central_node ;
>           <input_node_link> ?node_related .
>          BIND("IN" as ?inOutLabel )
>    }
>    UNION
>    {
>        [] <input_node_link> ?central_node ;
>           <output_node_link> ?node_related .
>          BIND("OUT" as ?inOutLabel )
>    }
>}
>
>Hope that helps
>Fabian
>
>
>
>
>Fabian Cretton
>Senior research assistant
>
>Data Semantics Lab
>www.hevs.ch/datasemlab
> 
>Email :fabian.cretton@hevs.ch
>Tél. / Tel. :027/606.90.05 
>
>http://www.hevs.ch 
>
>
> HES-SO Valais-Wallis • Techno-Pôle 3 • 3960 Sierre
>+41 27 606 90 01 • info.iig@hevs.ch • www.hevs.ch  
>
>
>
>Be green, keep it on the screen 
>
>
>>>> Mario Valle <mvalle@cscs.ch> 10.11.2016 06:33 >>>
>Dear SPARQL gurus,
>I have a graph, composed by nodes and link joining them, represented as
>
>triples. Now for a specific node I want to list the nodes that are 
>pointed FROM the given node or that point TO the given node. This is
>easy:
>
>SELECT  ?node_in ?node_out
>WHERE {
>
>    ?central_node a <node> ;
>        <id> 123 .
>    {
>        [] <output_node_link> ?central_node ;
>           <input_node_link> ?node_in .
>    }
>    UNION
>    {
>        [] <input_node_link> ?central_node ;
>           <output_node_link> ?node_out .
>    }
>}
>
>My question: instead of having two columns to distinguish linked node
>as 
>IN or OUT, is it possible to have a single ?node_related column and a 
>variable that says "IN" or "OUT"?
>
>I think I have to put before my query a CONSTRUCT that adds this field 
>to the related nodes, but I don't know if this field could be defined 
>"temporary" and does not modify the db content.
>
>Thanks for your help!
>            mario
>
>-- 
>Ing. Mario Valle
>Swiss National Supercomputing Centre (CSCS)
>v. Trevano 131, 6900 Lugano, Switzerland
>Tel: +41 (91) 610.82.60

-- 
Inviato da Galaxy Notes con K-9 Mail. Perdonate la brevità.

Received on Thursday, 10 November 2016 06:32:18 UTC