Dear Ken, I hope this example helps you:
String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]"; Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules)); reasoner.setDerivationLogging(true); InfModel inf = ModelFactory.createInfModel(reasoner, rawData); You can check more here: https://jena.apache.org/documentation/inference/index.html On 2020/05/13 01:28:29, Kenneth Keefe <[email protected]> wrote: > When you are working on rules like this with Jena, what tools do you use to > test? Is there an IDE for interfacing with Jena and building ontologies? > > Thanks, > Ken > > On Tue, May 12, 2020 at 1:44 AM Lorenz Buehmann < > [email protected]> wrote: > > > Hi, > > > > I think the rule would be basically > > > > [r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig), > > regex(?sig, '(.*) (.*)', ?first, ?last) -> (?x ex:hasFirstName > > ?first), (?x ex:hasLastName ?last), (?x rdf:type ex:Person) ) ] > > > > Note, it's untested and you have to define your prefix ex: in the rules > > file. You might also have to adapt the regex pattern to cover different > > white space chars. > > > > On 12.05.20 00:56, Kenneth Keefe wrote: > > > I am pretty new to using Jena and OWL. I have read many great tutorials > > > regarding RDF and OWL. The focus of those tutorials has largely been how > > to > > > structure the ontology and define restrictions on properties and such. > > > However, I have not been able to find good tutorials that explain how > > > inference is done and how I can define my own inference rules. I'm > > > wondering if I am simply not searching for the right thing. > > > > > > Regardless, here is a significant example that I think will really help > > me > > > get started with inference using Jena. I created a minimal example to > > > enable discussion. Here is a pastebin: https://pastebin.com/ScTGcbcZ > > > > > > The ontology has two classes, RosterEntry and Person and three data > > > properties, Signature (associated with RosterEntry), and FirstName and > > > LastName (both associated with Person). The example also has two > > > RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones." > > > > > > I would like to write a rule that causes Jena to infer the following new > > > facts: > > > > > > <owl:Individual> > > >> <rdf:type > > >> rdf:resource="http://example.com/ont/roster/Person" /> > > >> <hasFirstName>Bob</hasFirstName> > > > <hasLastName>Smith</hasLastName> > > > > > > </owl:Individual> > > > > > > > > > <owl:Individual> > > >> <rdf:type > > >> rdf:resource="http://example.com/ont/roster/Person" /> > > >> <hasFirstName>Sally</hasFirstName> > > > <hasLastName>Jones</hasLastName> > > > > > > </owl:Individual> > > > > > > > > > How do I do that? Full answers or nudges in the right direction are both > > > very welcome. Thank you! > > > > > > Ken > > > > > > > > > -- > ------- > Ken Keefe > Senior Software Engineer > Information Trust Institute > University of Illinois at Urbana-Champaign > 1308 W. Main St. > CSL 225 > Urbana, Illinois 61801, USA > Phone: 217-244-3203 > Web: https://www.perform.illinois.edu/~kjkeefe > Email: [email protected] >
