This is basically what I'm doing. "query" is the SPARQL query string. I
will turn it into a Model, modify it and then, I want to rebuild it.
SPINModuleRegistry.get().init();
// Create an empty OntModel importing SP
Model model = ModelFactory.createDefaultModel();
model.setNsPrefix("rdf", RDF.getURI());
model.setNsPrefix("dbpedia", "http://dbpedia.org/resource/");
Query arqQuery = ARQFactory.get().createQuery(model, query);
ARQ2SPIN arq2SPIN = new ARQ2SPIN(model);
Select spinQuery = (Select) arq2SPIN.createQuery(arqQuery, null);
// Then I add some rules to the model
Model modeloReglas = ModelFactory.createDefaultModel();
modeloReglas.read("reglas.ttl");
modeloConsulta.add(modeloReglas);
// And run the inferences (following another example from SPIN-API)
OntModel ontModel = JenaUtil.createOntologyModel(OntModelSpec.OWL_MEM,
modeloConsulta);
Model newTriples = ModelFactory.createDefaultModel();
ontModel.addSubModel(newTriples);
SPINInferences.run(ontModel, newTriples, null, null, false, null);
The inference rules add valid (I hope) triples to the SPIN SPARQL query.
At this point I have a model that has both a SPARQL Query (the original
with aditional parts) and some SPIN rules. I want to get the query from the
model (i can remove the rules from the model, if necesary).
There is a similar question in the mailing list, but in that case the
query was the body of a template, so it's easy to get the Resource. Here
the query it's something like this:
[ a <http://spinrdf.org/sp#Select> ;
<http://spinrdf.org/sp#resultVariables>
( [ <http://spinrdf.org/sp#varName>
"a"^^<http://www.w3.org/2001/XMLSchema#string> ] [
<http://spinrdf.org/sp#varName>
"b"^^<http://www.w3.org/2001/XMLSchema#string> ] [
<http://spinrdf.org/sp#varName>
"c"^^<http://www.w3.org/2001/XMLSchema#string> ] ) ;
<http://spinrdf.org/sp#where> ( [ <http://spinrdf.org/sp#object> [
<http://spinrdf.org/sp#varName>
"c"^^<http://www.w3.org/2001/XMLSchema#string> ] ;
<http://spinrdf.org/sp#predicate>
[
<http://spinrdf.org/sp#varName>
"b"^^<http://www.w3.org/2001/XMLSchema#string> ] ;
<http://spinrdf.org/sp#subject>
[
<http://spinrdf.org/sp#varName>
"a"^^<http://www.w3.org/2001/XMLSchema#string> ]
] )
] .
As I say early, probably the answer is trivial.
Thanks for your patience,
Jorge
On Wednesday, July 30, 2014 4:21:18 AM UTC-3, Holger Knublauch wrote:
>
> On 7/30/2014 15:42, Jorge Gastaldi wrote:
> >
> > Thanks for your answer!
> >
> >
> > I think that the problem is that I don't know how to create the Select
> > object ("spinQuery" in the example) without refering to the query
> string.
> >
> > From the example:
> > Select spinQuery = (Select) arq2SPIN.createQuery(arqQuery, null);
> >
> > arqQuery was created using the query String. I only have the Jena Model.
> >
> >
> > This is problably something trivial, but I'm quite at loss here.
>
> So is your starting point a Jena Resource instance? To convert that into
> a Select, use SPINFactory.asQuery(resource)
>
> If this doesn't help, I need to see a source code snippet where you are
> stuck.
>
> HTH
> Holger
>
>
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary
Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight,
SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.