|
Aziza, I take it you refer to a SPARQL Template using SPIN.
The introduction on the TBC SPIN page is quite useful
(http://www.topquadrant.com/products/SPIN.html), as is the
tutorial, both of which will help you with this problem. The
TopBraid/Examples/kennedysSPIN model has some good examples. See
the Person class. Any argument can be passed to a template. The steps to create a template and add to a rule are as follows which you can observe in the example file I have attached (the .tbc configures inferencing to use TopSPIN). 1) Create a template class, which is a subclass of spin:Templates. See ex:ContractType in the example. 2) Create a property for the argument. sp:arg1, etc., can be used, but it's always good to have a sensible name. I created a subproperty of sp:arg (I use this convention to name properties I use as function arguments) named sp:contractClass. You can use any property. 3) Specify the property as a constraint for the template class. The easiest way to do this is to drag/drop the property on to the spin:constraint property name in the template class. The valueType can be constrained to the type you are expecting, owl:Class in this case. 4) Edit the body of the template using the argument where desired. 5) Document how the template will appear by editing the spin:labelTemplate property. This is a helpful feature, as you can design rules with descriptive statements that document the rules, helping readability and maintenance. 6) To use the template as a rule, in the spin:rule of the class you want to run the template on, choose "Create from SPIN template" from the context menu (triangle next to the name spin:rule). Choose your template (ex:ContractType in my example) and fill in the value(s) for the arguments. I did this for ex:Bank in the example. If you run the example, an untyped resource is inferred to be a member of ex:ContractA. Hopefully, that can get you started. Let us know if you have further questions. -- Scott On 3/3/11 3:14 AM, aziza wrote: -- You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include TopBraid Composer, TopBraid Live, TopBraid Ensemble, SPARQLMotion 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 |
# Saved by TopBraid on Thu Mar 03 09:45:29 CST 2011 # baseURI: null @prefix composite: <http://www.topbraid.org/2007/05/composite.owl#> . @prefix forms: <http://www.topbraid.org/2007/01/forms.owl#> . @prefix inference: <http://www.topbraid.org/2007/06/inference.owl#> . @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 visual: <http://topbraid.org/visual#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . [] rdf:type inference:Configuration ; composite:child [ rdf:type <http://spinrdf.org/spin#TopSPIN> ; composite:index "0"^^xsd:int ] .
# Saved by TopBraid on Thu Mar 03 09:45:29 CST 2011 # baseURI: http://support.tq.com/ex # imports: http://spinrdf.org/spin @prefix ex: <http://support.tq.com/ex#> . @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 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#> . sp:contractClass rdf:type rdf:Property ; rdfs:label "contract class"^^xsd:string ; rdfs:subPropertyOf sp:arg . <http://support.tq.com/ex> rdf:type owl:Ontology ; owl:imports <http://spinrdf.org/spin> ; owl:versionInfo "Created with TopBraid Composer"^^xsd:string . ex:Bank rdf:type owl:Class ; rdfs:label "Bank"^^xsd:string ; rdfs:subClassOf owl:Thing ; spin:rule [ rdf:type ex:ContractType ; sp:contractClass ex:ContractA ] . ex:Bank_1 rdf:type ex:Bank ; rdfs:label "Bank 1"^^xsd:string . ex:ContractA rdf:type owl:Class ; rdfs:label "Contract a"^^xsd:string ; rdfs:subClassOf owl:Thing . ex:ContractType rdf:type spin:Template ; rdfs:label "Contract type"^^xsd:string ; rdfs:subClassOf spin:Templates ; spin:body [ rdf:type sp:Construct ; sp:templates ([ sp:object [ sp:varName "contractClass"^^xsd:string ] ; sp:predicate rdf:type ; sp:subject _:b1 ]) ; sp:where ([ sp:object _:b2 ; sp:predicate ex:hasProcess ; sp:subject _:b1 ] [ sp:object _:b3 ; sp:predicate ex:hasInitiator ; sp:subject _:b2 ] [ sp:object ex:Bank ; sp:predicate rdf:type ; sp:subject _:b3 ] [ sp:object _:b4 ; sp:predicate ex:hasRecipient ; sp:subject _:b2 ] [ sp:object ex:Supplier ; sp:predicate rdf:type ; sp:subject _:b4 ]) ] ; spin:constraint [ rdf:type spl:Argument ; spl:predicate sp:contractClass ; spl:valueType owl:Class ] ; spin:labelTemplate "Infer instances of {?contractClass}"^^xsd:string . ex:Process rdf:type owl:Class ; rdfs:label "Process"^^xsd:string ; rdfs:subClassOf owl:Thing . ex:Process_1 rdf:type ex:Process ; rdfs:label "Process 1"^^xsd:string ; ex:hasInitiator ex:Bank_1 ; ex:hasRecipient ex:Supplier_1 . ex:Supplier rdf:type owl:Class ; rdfs:label "Supplier"^^xsd:string ; rdfs:subClassOf owl:Thing . ex:Supplier_1 rdf:type ex:Supplier ; rdfs:label "Supplier 1"^^xsd:string . ex:aContract rdf:type owl:Thing ; rdfs:label "a contract"^^xsd:string ; ex:hasProcess ex:Process_1 . ex:hasInitiator rdf:type owl:ObjectProperty ; rdfs:label "has initiator"^^xsd:string . ex:hasProcess rdf:type owl:ObjectProperty ; rdfs:label "has process"^^xsd:string . ex:hasRecipient rdf:type owl:ObjectProperty ; rdfs:label "has recipient"^^xsd:string . _:b4 sp:varName "r1"^^xsd:string . _:b3 sp:varName "i1"^^xsd:string . _:b2 sp:varName "p1"^^xsd:string . _:b1 sp:varName "contract"^^xsd:string .
