Thanks Dave again, yes I was asking something like that. You answered what I want.
Cheers On Sat, Dec 3, 2016 at 9:24 PM, Dave Reynolds <[email protected]> wrote: > On 03/12/16 17:29, javed khan wrote: > >> Thank you Dave, I have a class "Expert", which have sub classes Researcher >> and Teacher. >> I have Jena rule like: If an Expert ResearchPapers more than 10, assign >> the >> individual to Researcher sub class otherwise to Teacher subclass. >> After writing the appropriate Jena rule, apart from SPARQL query >> >> Select * Where{ ?ind rdf:type ont:Researcher . ?ind rdf:type ont:Teacher} >> >> What is the alternate way to parse/execute the rule and the result >> transfers to our infmodel. ? >> > > Sorry, still don't quite understand what you are asking. > > There is no alternative way to "parse/execute" the rule other that to pass > it to a GenericRuleReasoner instance and create an InfModel. At least no > alternative built into Jena. > > To then list all individuals that your rule has classified as a Researcher > then running a SPARQL query as you are is perfectly fine. > > If you want to do that with the RDF API then it would be something like: > > OntClass researcherClass = infModel.getResource(namespace + > "Researcher"); > ResIterator i = infModel.listResourcesWithProperty(RDF.type, > researcherClass); > while (i.hasNext()){ > Resource instance = i.next(); > ... > } > > Dave > > > >> On Sat, Dec 3, 2016 at 8:06 PM, Dave Reynolds <[email protected]> >> wrote: >> >> On 03/12/16 16:05, javed khan wrote: >>> >>> My question is what are the possible ways to implement the Jena rules? >>>> Is it necessary that we should always execute the SPARQL query to >>>> implement >>>> the rules? If not, what are the alternatives? >>>> >>>> What if we just write rules in our Java code and do nothing other than: >>>> >>>> Reasoner myreasoner = new GenericRuleReasoner(Rule.parseRules(rule)); >>>> InfModel infmodel = ModelFactory.createInfModel(myreasoner, model); >>>> >>>> >>> Sorry, don't follow the question. >>> >>> Jena rules are the syntax for the built in Jena generic rules engine >>> which >>> can be run as you show above. >>> >>> You don't "implement the rules" by executing sparql queries you just run >>> the rules engine. You could compute the same results through using a >>> sequence of SPARQL queries and updates or through java code but that's >>> not >>> the same thing as implementing the rules unless you have some sort of >>> jena-rules to "sequence of sparql updates" converter. >>> >>> If you are talking about getting results out after running the rules then >>> your choices are SPARQL or the RDF API. >>> >>> Dave >>> >>> >>> >>> >> >
