/** * Constructor method that builds an instance of the associated Reasoner * @param configuration a set of arbitrary configuration information to be * passed the reasoner encoded within an RDF graph */ @Override public Reasoner create(Resource configuration) { OWLFBRuleReasoner reasoner = new OWLFBRuleReasoner(this); if (configuration != null) { Boolean doLog = Util.checkBinaryPredicate(ReasonerVocabulary.PROPderivationLogging, configuration); if (doLog != null) { reasoner.setDerivationLogging(doLog.booleanValue()); } Boolean doTrace = Util.checkBinaryPredicate(ReasonerVocabulary.PROPtraceOn, configuration); if (doTrace != null) { reasoner.setTraceOn( doTrace ); } } return reasoner; }
/** * Constructor */ public OWLFBRuleReasoner(ReasonerFactory factory) { super(loadRules(), factory); }
/** * Precompute the implications of a schema graph. The statements in the graph * will be combined with the data when the final InfGraph is created. */ @Override public Reasoner bindSchema(Graph tbox) throws ReasonerException { checkArgGraph(tbox); if (schemaGraph != null) { throw new ReasonerException("Can only bind one schema at a time to an OWLRuleReasoner"); } FBRuleInfGraph graph = new FBRuleInfGraph(this, rules, getPreload(), tbox); graph.addPreprocessingHook(new OWLRuleTranslationHook()); graph.prepare(); return new OWLFBRuleReasoner(this, graph); }
/** * Check cost of creating an empty OWL closure. */ public void temp() { Graph data = Factory.createGraphMem(); Graph data2 = Factory.createGraphMem(); Reasoner reasoner = new OWLFBRuleReasoner(OWLFBRuleReasonerFactory.theInstance()); FBRuleInfGraph infgraph = (FBRuleInfGraph)reasoner.bind(data); FBRuleInfGraph infgraph2 = (FBRuleInfGraph)reasoner.bind(data2); long t1 = System.currentTimeMillis(); infgraph.prepare(); long t2 = System.currentTimeMillis(); System.out.println("Prepare on empty graph = " + (t2-t1) +"ms"); t1 = System.currentTimeMillis(); infgraph2.prepare(); t2 = System.currentTimeMillis(); System.out.println("Prepare on empty graph = " + (t2-t1) +"ms"); }
/** * Attach the reasoner to a set of RDF data to process. * The reasoner may already have been bound to specific rules or ontology * axioms (encoded in RDF) through earlier bindRuleset calls. * * @param data the RDF data to be processed, some reasoners may restrict * the range of RDF which is legal here (e.g. syntactic restrictions in OWL). * @return an inference graph through which the data+reasoner can be queried. * @throws ReasonerException if the data is ill-formed according to the * constraints imposed by this reasoner. */ @Override public InfGraph bind(Graph data) throws ReasonerException { checkArgGraph(data); FBRuleInfGraph graph = null; InfGraph schemaArg = schemaGraph == null ? getPreload() : (FBRuleInfGraph)schemaGraph; List<Rule> baseRules = ((FBRuleInfGraph)schemaArg).getRules(); graph = new FBRuleInfGraph(this, baseRules, schemaArg); graph.addPreprocessingHook(new OWLRuleTranslationHook()); graph.setDerivationLogging(recordDerivations); graph.setTraceOn(traceOn); graph.rebind(data); graph.setDatatypeRangeValidation(true); return graph; }
/** * Precompute the implications of a schema graph. The statements in the graph * will be combined with the data when the final InfGraph is created. */ @Override public Reasoner bindSchema(Graph tbox) throws ReasonerException { checkArgGraph(tbox); if (schemaGraph != null) { throw new ReasonerException("Can only bind one schema at a time to an OWLRuleReasoner"); } FBRuleInfGraph graph = new FBRuleInfGraph(this, rules, getPreload(), tbox); graph.addPreprocessingHook(new OWLRuleTranslationHook()); graph.prepare(); return new OWLFBRuleReasoner(this, graph); }
/** * Check cost of creating an empty OWL closure. */ public void temp() { Graph data = Factory.createGraphMem(); Graph data2 = Factory.createGraphMem(); Reasoner reasoner = new OWLFBRuleReasoner(OWLFBRuleReasonerFactory.theInstance()); FBRuleInfGraph infgraph = (FBRuleInfGraph)reasoner.bind(data); FBRuleInfGraph infgraph2 = (FBRuleInfGraph)reasoner.bind(data2); long t1 = System.currentTimeMillis(); infgraph.prepare(); long t2 = System.currentTimeMillis(); System.out.println("Prepare on empty graph = " + (t2-t1) +"ms"); t1 = System.currentTimeMillis(); infgraph2.prepare(); t2 = System.currentTimeMillis(); System.out.println("Prepare on empty graph = " + (t2-t1) +"ms"); }
/** * Attach the reasoner to a set of RDF data to process. * The reasoner may already have been bound to specific rules or ontology * axioms (encoded in RDF) through earlier bindRuleset calls. * * @param data the RDF data to be processed, some reasoners may restrict * the range of RDF which is legal here (e.g. syntactic restrictions in OWL). * @return an inference graph through which the data+reasoner can be queried. * @throws ReasonerException if the data is ill-formed according to the * constraints imposed by this reasoner. */ @Override public InfGraph bind(Graph data) throws ReasonerException { checkArgGraph(data); FBRuleInfGraph graph = null; InfGraph schemaArg = schemaGraph == null ? getPreload() : (FBRuleInfGraph)schemaGraph; List<Rule> baseRules = ((FBRuleInfGraph)schemaArg).getRules(); graph = new FBRuleInfGraph(this, baseRules, schemaArg); graph.addPreprocessingHook(new OWLRuleTranslationHook()); graph.setDerivationLogging(recordDerivations); graph.setTraceOn(traceOn); graph.rebind(data); graph.setDatatypeRangeValidation(true); return graph; }
/** * Constructor method that builds an instance of the associated Reasoner * @param configuration a set of arbitrary configuration information to be * passed the reasoner encoded within an RDF graph */ @Override public Reasoner create(Resource configuration) { OWLFBRuleReasoner reasoner = new OWLFBRuleReasoner(this); if (configuration != null) { Boolean doLog = Util.checkBinaryPredicate(ReasonerVocabulary.PROPderivationLogging, configuration); if (doLog != null) { reasoner.setDerivationLogging(doLog.booleanValue()); } Boolean doTrace = Util.checkBinaryPredicate(ReasonerVocabulary.PROPtraceOn, configuration); if (doTrace != null) { reasoner.setTraceOn( doTrace ); } } return reasoner; }
Model premisesM = FileManager.get().loadModel("file:testing/wg/equivalentClass/premises004.rdf"); Graph data = premisesM.getGraph(); Reasoner reasoner = new OWLFBRuleReasoner(OWLFBRuleReasonerFactory.theInstance()); InfGraph infgraph = reasoner.bind(data); Node rbPrototypeProp = NodeFactory.createURI(ReasonerVocabulary.RBNamespace+"prototype");
/** * Return the rule set, loading it in if necessary */ public static List<Rule> loadRules() { if (ruleSet == null) ruleSet = loadRules( RULE_FILE ); return ruleSet; }
Model premisesM = FileManager.get().loadModel("file:testing/wg/equivalentClass/premises004.rdf"); Graph data = premisesM.getGraph(); Reasoner reasoner = new OWLFBRuleReasoner(OWLFBRuleReasonerFactory.theInstance()); InfGraph infgraph = reasoner.bind(data); Node rbPrototypeProp = NodeFactory.createURI(ReasonerVocabulary.RBNamespace+"prototype");
/** * Return the rule set, loading it in if necessary */ public static List<Rule> loadRules() { if (ruleSet == null) ruleSet = loadRules( RULE_FILE ); return ruleSet; }
/** * Constructor */ public OWLFBRuleReasoner(ReasonerFactory factory) { super(loadRules(), factory); }
preloadedRules.addAll( OWLFBRuleReasoner.loadRules() ) ;
preloadedRules.addAll( OWLFBRuleReasoner.loadRules() ) ;