Ok, if there is a TBL server in the mix then we can rely on SPARQLMotion
(or SWP) to perform inferencing. This could theoretically happen on the
fly for each request, e.g. by calling a SPARQLMotion script with
parameters. But this would have the server re-apply the inferences for
each individual request, and may not be performant. So one possible work
flow would be to have a small SM script that applies inferences and
produces a new named graph (e.g. TTL file or TDB), and then query that
new named graph with the usual SPARQL end point. You would call this
script before you want to query or periodically if the data changes.
I have attached an SM file that you can put into your TBL workspace
(e.g. via project upload). An example call using TBC-ME would be
http://localhost:8083/tbl/sparqlmotion?id=createInfGraph:CreateInfGraph&graphName=http://topbraid.org/examples/kennedysSPIN
The script looks like:
The produces a stand-alone graph with all inferences which you can then
query using the SPARQL end point, e.g.
SELECT *
WHERE {
GRAPH <http://topbraid.org/examples/kennedysSPIN-withSPIN> {
?subject a <http://topbraid.org/examples/kennedys#Person> .
}
} ORDER BY ?subject
HTH
Holger
On 18/02/2017 6:05, Russell Morrisey wrote:
Holger,
Thanks for your reply.
The current (prototype) version of the app calls out to the SPARQL
REST endpoint in TopBraid Live:
http://localhost:8083/tbl/sparql
If there is a better way I should do this, please point me to the
right approach.
I don't know how to tell the sparql endpoint that it should execute
SPIN rules. The SPIN rule declaration is stored in the ontology as
part of the Class definition. Here is the Class definition, including
the rule declaration:
|
spinTest:SpinTest
rdf:type owl:Class ;
spin:rule [
rdf:type sp:Construct ;
sp:templates (
[
sp:object "spin:rule OK" ;
sp:predicate spinTest:testResult ;
sp:subject [
sp:varName "test" ;
] ;
]
) ;
sp:where (
[
sp:object spinTest:SpinTest ;
sp:predicate rdf:type ;
sp:subject [
sp:varName "test" ;
] ;
]
) ;
] ;
rdfs:label "Spin test" ;
rdfs:subClassOf owl:Thing ;
.
|
I have tested out this rule using "Run Inferences" in Composer, but I
don't understand how to apply it on the server.
Thanks
On Thursday, February 16, 2017 at 11:40:58 PM UTC-5, Holger Knublauch
wrote:
Hi Russell,
in your question you indicate that you have a Java app, so I
assume this code runs outside of the TBL server. Assuming you want
to perform the inferences in your code using the SPIN API, I guess
there is no difference between TBL or any 3rd party triple store -
you can for example use the SPARQL end point to retrieve the
original triples. Everything else is under full control of your
application.
Is this the scenario you are describing?
Thanks,
Holger
On 17/02/2017 8:59, Russell Morrisey wrote:
I have an ontology with a *spin:rule* that I've built and tested
in TopBraid Composer.
I'd like to build an app that has the following flow:
1. Load some graph data from a triple store
2. Assert some triples from the client into a temporary graph
(preferably a session-scoped graph)
3. Run my spin:rules and store the new triples in the temporary
graph
4. Query the temporary graph and send the results back to the
caller.
My app is a Java app which does not use SWP.
How can I apply spin:rules this way when my ontology is deployed
in TopBraid Live?
How can I apply spin:rules this way when my ontology is in a
3rd-party triple store?
Which 3rd-party triple stores support this?
I am working on figuring out the answers to these questions. Any
help would be appreciated.
--
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 [email protected]
<javascript:>
---
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] <javascript:>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
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 [email protected]
---
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]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected]
---
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.
# baseURI: http://example.org/createInfGraph
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib-tb
# prefix: createInfGraph
@prefix createInfGraph: <http://example.org/createInfGraph#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sm: <http://topbraid.org/sparqlmotion#> .
@prefix smf: <http://topbraid.org/sparqlmotionfunctions#> .
@prefix sml: <http://topbraid.org/sparqlmotionlib#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix spl: <http://spinrdf.org/spl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example.org/createInfGraph>
rdf:type owl:Ontology ;
owl:imports <http://topbraid.org/sparqlmotionfunctions> ;
owl:imports <http://topbraid.org/sparqlmotionlib-tb> ;
owl:versionInfo "Created with TopBraid Composer" ;
.
createInfGraph:ApplyTopSPIN_1
rdf:type sml:ApplyTopSPIN ;
sm:next createInfGraph:ExportToRDFFile_1 ;
sml:predicate spin:rule ;
rdfs:label "Apply top SPIN 1" ;
.
createInfGraph:CreateInfGraph
rdf:type sm:Function ;
spin:constraint [
rdf:type spl:Argument ;
spl:predicate sml:graphName ;
spl:valueType xsd:string ;
sm:next createInfGraph:ImportRDFFromWorkspace_1 ;
rdfs:comment "The URI of the input graph." ;
] ;
sm:returnModule createInfGraph:CreateInfGraph_Return ;
rdfs:comment "Takes a graph with a given URI as input and applies SPIN
inferences over it, then saves the results to a new graph." ;
rdfs:subClassOf sm:Functions ;
.
createInfGraph:CreateInfGraph_Return
rdf:type sml:ReturnText ;
sml:fileName "result" ;
sml:mimeType "text" ;
sml:text "OK" ;
.
createInfGraph:ExportToRDFFile_1
rdf:type sml:ExportToRDFFile ;
sm:next createInfGraph:CreateInfGraph_Return ;
sml:baseURI [
rdf:type sp:concat ;
sp:arg1 [
sp:varName "graphName" ;
] ;
sp:arg2 "-withSPIN" ;
] ;
sml:targetFilePath [
rdf:type sp:concat ;
sp:arg1 [
rdf:type smf:file ;
sp:arg1 [
rdf:type sp:iri ;
sp:arg1 [
sp:varName "graphName" ;
] ;
] ;
] ;
sp:arg2 ".withSPIN.ttl" ;
] ;
rdfs:label "Export to RDFFile 1" ;
.
createInfGraph:ImportRDFFromWorkspace_1
rdf:type sml:ImportRDFFromWorkspace ;
sm:next createInfGraph:ApplyTopSPIN_1 ;
sml:baseURI [
sp:varName "graphName" ;
] ;
sml:ignoreImports "false"^^xsd:boolean ;
rdfs:label "Import RDFFrom workspace 1" ;
.