/** * Build an inferred model by attaching the given RDF model to the given reasoner. * This form of the call allows two data sets to be merged and reasoned over - * conventionally one contains schema data and one instance data but this is not * a formal requirement. * * @param reasoner the reasoner to use to process the data * @param schema a Model containing RDFS schema data * @param model a Model containing instance data assertions, any statements added to the InfModel * will be added to this underlying data model. */ public static InfModel createInfModel(Reasoner reasoner, Model schema, Model model) { InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); return new InfModelImpl( graph ); }
/** * Build an inferred model by attaching the given RDF model to the given reasoner. * * @param reasoner the reasoner to use to process the data * @param model the Model containing both instance data and schema assertions to be inferenced over, * any statements added to the InfModel will be added to this underlying data model. */ public static InfModel createInfModel( Reasoner reasoner, Model model ) { InfGraph graph = reasoner.bind(model.getGraph()); return new InfModelImpl(graph); }
/** * Build an inferred model by attaching the given RDF model to the given reasoner. * * @param reasoner the reasoner to use to process the data * @param model the Model containing both instance data and schema assertions to be inferenced over, * any statements added to the InfModel will be added to this underlying data model. */ public static InfModel createInfModel( Reasoner reasoner, Model model ) { InfGraph graph = reasoner.bind(model.getGraph()); return new InfModelImpl(graph); }
/** * Build an inferred model by attaching the given RDF model to the given reasoner. * This form of the call allows two data sets to be merged and reasoned over - * conventionally one contains schema data and one instance data but this is not * a formal requirement. * * @param reasoner the reasoner to use to process the data * @param schema a Model containing RDFS schema data * @param model a Model containing instance data assertions, any statements added to the InfModel * will be added to this underlying data model. */ public static InfModel createInfModel(Reasoner reasoner, Model schema, Model model) { InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); return new InfModelImpl( graph ); }
/** * Return a Model through which all the RDFS entailments * derivable from the given model are accessible. Some work is done * when the inferenced model is created but each query will also trigger some * additional inference work. * * @param model the Model containing both instance data and schema assertions to be inferenced over */ public static InfModel createRDFSModel(Model model) { Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); InfGraph graph = reasoner.bind( model.getGraph() ); return new InfModelImpl( graph ); }
/** * Return a Model through which all the RDFS entailments * derivable from the given data and schema models are accessible. * There is no strict requirement to separate schema and instance data between the two * arguments. * * @param model a Model containing instance data assertions * @param schema a Model containing RDFS schema data */ public static InfModel createRDFSModel( Model schema, Model model ) { Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); return new InfModelImpl( graph ); }
/** * Return a Model through which all the RDFS entailments * derivable from the given model are accessible. Some work is done * when the inferenced model is created but each query will also trigger some * additional inference work. * * @param model the Model containing both instance data and schema assertions to be inferenced over */ public static InfModel createRDFSModel(Model model) { Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); InfGraph graph = reasoner.bind( model.getGraph() ); return new InfModelImpl( graph ); }
/** * Return a Model through which all the RDFS entailments * derivable from the given data and schema models are accessible. * There is no strict requirement to separate schema and instance data between the two * arguments. * * @param model a Model containing instance data assertions * @param schema a Model containing RDFS schema data */ public static InfModel createRDFSModel( Model schema, Model model ) { Reasoner reasoner = ReasonerRegistry.getRDFSReasoner(); InfGraph graph = reasoner.bindSchema(schema.getGraph()).bind(model.getGraph()); return new InfModelImpl( graph ); }
@Override protected MultiValueMap<ATermAppl, ATermAppl> run(final Collection<ATermAppl> classes) { addClasses(classes); addClasses(_names.getAllAnons()); final Reasoner reasoner = new GenericRuleReasoner(new ArrayList<>(_rules)); final InfGraph inf = reasoner.bind(_facts); inf.prepare(); final MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for (final ATermAppl c : classes) subsumers.add(ATermUtils.BOTTOM, c); return subsumers; }
@Override protected MultiValueMap<ATermAppl, ATermAppl> run(final Collection<ATermAppl> classes) { addClasses(classes); addClasses(_names.getAllAnons()); final Reasoner reasoner = new GenericRuleReasoner(new ArrayList<>(_rules)); final InfGraph inf = reasoner.bind(_facts); inf.prepare(); final MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for (final ATermAppl c : classes) subsumers.add(ATermUtils.BOTTOM, c); return subsumers; }
@Override protected MultiValueMap<ATermAppl, ATermAppl> run(final Collection<ATermAppl> classes) { addClasses(classes); addClasses(_names.getAllAnons()); final Reasoner reasoner = new GenericRuleReasoner(new ArrayList<>(_rules)); final InfGraph inf = reasoner.bind(_facts); inf.prepare(); final MultiValueMap<ATermAppl, ATermAppl> subsumers = getSubsumptions(inf); for (final ATermAppl c : classes) subsumers.add(ATermUtils.BOTTOM, c); return subsumers; }
/** * <p>Helper method to the constructor, which interprets the spec and generates an appropriate * graph for this model</p> * @param spec The model spec to interpret * @param base The base model, or null */ private static Graph generateGraph( OntModelSpec spec, Graph base ) { // create a empty union graph MultiUnion u = new MultiUnion(); u.addGraph( base ); u.setBaseGraph( base ); Reasoner r = spec.getReasoner(); // if we have a reasoner in the spec, bind to the union graph and return return r == null ? (Graph) u : r.bind( u ); }
/** * <p>Helper method to the constructor, which interprets the spec and generates an appropriate * graph for this model</p> * @param spec The model spec to interpret * @param base The base model, or null */ private static Graph generateGraph( OntModelSpec spec, Graph base ) { // create a empty union graph MultiUnion u = new MultiUnion(); u.addGraph( base ); u.setBaseGraph( base ); Reasoner r = spec.getReasoner(); // if we have a reasoner in the spec, bind to the union graph and return return r == null ? (Graph) u : r.bind( u ); }
/** * Assemble a test infGraph from a rule source and starting data */ public InfGraph createInfGraph(String rules, Graph data) { return createReasoner( Rule.parseRules(rules) ).bind(data); }
/** * Assemble a test infGraph from a rule source and starting data */ public InfGraph createInfGraph(String rules, Graph data) { return createReasoner( Rule.parseRules(rules) ).bind(data); }
/** * Assemble a test infGraph from a rule source and empty data */ public InfGraph createInfGraph(String rules) { return createReasoner( Rule.parseRules(rules) ).bind(Factory.createGraphMem()); }
/** * Assemble a test infGraph from a rule source and empty data */ public InfGraph createInfGraph(String rules) { return createReasoner( Rule.parseRules(rules) ).bind(Factory.createGraphMem()); }
/** * Test basic builtin usage. */ public void testBuiltin3() { Graph data = Factory.createGraphMem(); List<Rule> rules = Rule.parseRules( "[r1: (a p b ) <- unbound(?x) ]" ); Reasoner reasoner = createReasoner(rules); InfGraph infgraph = reasoner.bind(data); TestUtil.assertIteratorValues(this, infgraph.find(a, null, null), new Object[] { new Triple(a, p, b) } ); }
public void testCreateInfModel() { final String rule = "-> (eg:r eg:p eg:v)."; final Reasoner r = new GenericRuleReasoner(Rule.parseRules(rule)); final InfGraph ig = r .bind(ModelFactory.createDefaultModel().getGraph()); final InfModel im = ModelFactory.createInfModel(ig); JenaTestBase.assertInstanceOf(InfModel.class, im); Assert.assertEquals(1, im.size()); }
public void testCreateInfModel() { final String rule = "-> (eg:r eg:p eg:v)."; final Reasoner r = new GenericRuleReasoner(Rule.parseRules(rule)); final InfGraph ig = r .bind(ModelFactory.createDefaultModel().getGraph()); final InfModel im = ModelFactory.createInfModel(ig); JenaTestBase.assertInstanceOf(InfModel.class, im); Assert.assertEquals(1, im.size()); }