Hi, Your attachment didn't come through. Indeed I don't know if the apache lists allow attachments anyway.
The forward rule engine is normally run when data is requested - e.g. a SPARQL query or a listStatements or similar call, all of which translate into find() calls at the graph level. You can force the engine to run by called prepare() on the InfModel (or the underlying graph). The InfGraph maintains an internal flag to say if the data is ready for reading (isPrepared). A find() or an explicit prepare() checks that flag and if false it runs the engine to a stable state then sets the flag to true. The flag will be reset if you rebind() the data or if you delete a triple. However, simply adding a triple to an InfGraph that is already prepared will be handled incrementally there and then and won't reset the flag. Dave On Fri, 2011-06-24 at 01:09 -0700, Wang Wusheng wrote: > Dear Jena Developer, > I am a Ph.D student in PKU in Beijing, China. I am now learnning > about Jena. I can find many materials on the web to teach me how to > use Jena API, but very few about how Jena works. I just confuse > about the mechanism that Jena work with rules. > I wrote a simple test class with java to make jena API work with a > simple rule. The source code is in the attachment. > > In this code, I add two triple((a, p, b), and (b, p, c)) into a > graph, and with a rule(r1) to find the triple(a,p,c). However, I > cannot find out how Jena API work out the reasoning task and figure > out the new triple. > Since I print(?a,?c) when the rule works, in order to find out when > does the application work with the rule. It seems that after the > sentence "ExtendedIterator<Triple> triples = infgraph.find(null, p, > null);", the app print out "a, c". So during which sentence(it seems > "infgraph.find(null, p, null)", but not "infgraph = > reasoner.bind(test)") does the application find out the new triple, > and when does the Rete algorithm works? > > Thank your. > Best wishes. > -- > Wang Wusheng > Research Center for Modern Services > 1020 Resource Plaza, Peking University, 100871 > Email: [email protected] > [email protected] > TEL: +8610 62752177
