CWM DBpedia Slurp Rules Weirdness

I'm writing some N3 that looks for dbpedia URIs in some RDF input,
grabs them, and then outputs all of the triples that it finds. I'm
running into problems.

Here's how I get the input file:

{ "1" os:argv [ os:baseAbsolute ?URI ] .
  ?F log:uri ?URI; log:semantics ?G }
 => { ?G a :InputGraph } .

cwm dbpedia-slurp.n3 --think --purge --with input.n3

That bit works. This, however, doesn't work:

{ ?G a :InputGraph; log:includes { ?s ?p ?o } .
  ?o log:uri [ string:startsWith "http://dbpedia.org/resource/" ] .
  ?o log:semantics [ log:includes { ?a ?b ?c } ] }
   => { ?a ?b ?c } .

So I thought, it shouldn't need this, but let's try adding a universal:

{ ?G a :InputGraph; log:includes { ?s ?p ?o } .
  ?o log:uri [ string:startsWith "http://dbpedia.org/resource/" ] .
  ?o log:semantics ?H .
  ?H log:includes { ?a ?b ?c } }
   => { ?a ?b ?c } .

Now that didn't work either. But! (and this is the first weird bit)
when I *duplicated* that rule (accidentally) in the file, it worked!

So then I thought okay, I'll break it up:

{ ?G a :InputGraph; log:includes { ?s ?p ?o } .
  ?o log:uri [ string:startsWith "http://dbpedia.org/resource/" ] }
 => { ?o a :Entry } .

{ ?o a :Entry; log:semantics ?H }
 => { ?H a :EntryGraph } .

{ ?H a :EntryGraph; log:includes { ?s ?p ?o } }
 => { ?s ?p ?o } .

Guess what? Doesn't work—doesn't do a thing. But during the
incremental writing of it, it had been working... so what had changed?
Was it the order? Surely not?

{ ?H a :EntryGraph; log:includes { ?s ?p ?o } }
 => { ?s ?p ?o } .

{ ?o a :Entry; log:semantics ?H }
 => { ?H a :EntryGraph } .

{ ?G a :InputGraph; log:includes { ?s ?p ?o } .
  ?o log:uri [ string:startsWith "http://dbpedia.org/resource/" ] }
 => { ?o a :Entry } .

Surely so. That doesn't give the full output, but it did give me some
:EntryGraph instances, which is a near success. Changing the order of
the rules breaks or makes the output. But why isn't that first rule
firing still? Perhaps it needs the whole duplication thing done again?

{ ?H a :EntryGraph; log:includes { ?s ?p ?o } }
 => { ?s ?p ?o } .

{ ?o a :Entry; log:semantics ?H }
 => { ?H a :EntryGraph } .

{ ?G a :InputGraph; log:includes { ?s ?p ?o } .
  ?o log:uri [ string:startsWith "http://dbpedia.org/resource/" ] }
 => { ?o a :Entry } .

{ ?H a :EntryGraph; log:includes { ?s ?p ?o } }
 => { ?s ?p ?o } .

And yes, it does; that works just fine. Commenting out the first of
those rules, even though the last of the rules is exactly the same,
breaks it entirely. Commenting out the second rule only breaks it
partially, because you still get the :EntryGraph instances. You need
the duplication and that order.

Good luck debugging this!

Also note that I'm doing a --purge on the command line but there
aren't any log:Chaff statements in the file because if I add any then
that hoses it no matter what the order and contents of the rules, as
if the Chaffing is taking place way before output, some place during
the --think. Presumably that shouldn't be the case.

I've also tried doing the rules without --purge in the command line at
all, just in case that was affecting it somehow even without the
Chaffs around, and no, the weirdness still occurs.

I'm using cwm-1.2.0a1.

-- 
Sean B. Palmer, http://inamidst.com/sbp/

Received on Friday, 12 October 2007 08:09:29 UTC