SPIN query to SPARQL from external triple storage

40 views
Skip to first unread message

hoan...@insight-centre.org

unread,
Dec 8, 2016, 3:18:09 PM12/8/16
to TopBraid Suite Users
Hi all,

I'm a new user of SPIN. I'm able to convert the SPARQL query into SPIN syntax. The SPIN query will then be stored in the external triple storage (Jena TDB, Virtuoso,...) so I can do some analytic later on. However, it leads to the problem when I'm trying to convert back from SPIN query to SPARQL. My assumption is that, in order to convert back SPIN query to SPARQL, I might need to retrieve all the SPIN triples and save into a jena model. Then, I will be able to convert back to original SPARQL. My question is, how I can write the SPARQL query to get back all the SPIN triples from the external triple storage, or is there any sufficient way to do that?

Thanks a million

Holger Knublauch

unread,
Dec 8, 2016, 7:44:51 PM12/8/16
to topbrai...@googlegroups.com
Hi,

if I understand your question correctly, your main issue is the ease of converting from SPIN RDF triples back to an executable SPARQL string? The easiest way to do that might be to store your queries using sp:text. Search for sp:text in http://spinrdf.org/sp.html for examples:

  [ a       sp:Ask ;
                sp:text """
                    # must be at least 18 years old
                    ASK WHERE {
                        ?this my:age ?age .
                        FILTER (?age < 18) .
                    }"""
    ]

This way, you don't need another SPIN converter and can retrieve the SPARQL strings with a simple query.

Does this help?

Holger
--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include the TopBraid Suite family of products and its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbrai...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nguyen Mau Quoc Hoan

unread,
Dec 9, 2016, 3:38:41 AM12/9/16
to TopBraid Suite Users
Hi Holger,

Thanks for your quick reply. You're correct, using the sp:text might be the solution. However, when I use SPIN API to convert SPARQL query to SPIN query, it seems there is no sp:text. I followed the SPIN example:

Query arqQuery = ARQFactory.get().createQuery(model, query);

 ARQ2SPIN arq2SPIN
= new ARQ2SPIN(model);

 
Select spinQuery = (Select) arq2SPIN.createQuery(arqQuery, null);



Can you please point me to which API I should use to add the sp:text ?

Thanks,

Hoan

Holger Knublauch

unread,
Dec 11, 2016, 6:09:30 PM12/11/16
to topbrai...@googlegroups.com
There is no API for that, because once the ARQ Query object has been created, the original string (as entered by the user) is gone. But creating such queries is quite easy - simply create the two triples through the normal Jena API calls, or use the code below and add

    spinQuery.addProperty(SP.text, string);

HTH
Holger

hoan...@insight-centre.org

unread,
Dec 14, 2016, 7:09:32 AM12/14/16
to TopBraid Suite Users
Thanks a million Holger,

I'm able to add the SP.text and retrieve the query back.

Regards,

Hoan
Reply all
Reply to author
Forward
0 new messages