[redland] perl or commandline interface to raptor?
Dan Brickley
danbri at w3.org
Wed Nov 21 17:40:50 GMT 2001
> The distribution perl/example.pl code can be cut down to do this.
oh cool; I didn't have/need Berkeley DB so it died with 'failed to create
storage' and I started looking elsewhere (test.pl) and got lost.
> Customising it for raptor, and deleting all error checking gives:
>
> use RDF;
> my $uri=new RDF::URI("file:$test_file");
> my $parser=new RDF::Parser('raptor');
> my $stream=$parser->parse_as_stream($uri,$uri);
> while(!$stream->end) {
> print "Statement: ",$stream->next->as_string,"\n";
> }
> $stream=undef;
cool, that works :)
redparse /opt/mozilla/defaults/profile/JP/search.rdf
gives...
Statement: {[urn:search:category:1], [http://home.netscape.com/NC-rdf#title], "Webf$
g4"c5c$c"}
...etc
More RTFM questions: does Redland keep track of the
blankness/anonymity/genidness of nodes? From quick look I can't see how,
unless genid nodes have null or specially stringified URI content.
btw re:
my $node2=RDF::Node->new_from_uri_string("http://example.com/";);
my $node3=RDF::Node->new_from_uri(new RDF::URI("http://example.com/";));
...in my RDF::RDFWeb::Node class I was doing something similar, but with
an extra parameter which was a reference to the graph/database the node
was affiliated with. And I'm probably going to switch things so you do
my $node = $mygraph->newURINode('http://etc');
or (cos I often want to create a whole bunch at once),
my @nodes = $mygraph->newURINode(@people);
...wondering if you'd looked at doing something like this in your stuff.
This is not dissimilar to Jena's node-centric view, except that nodes are
more loosly coupled to their datasource(s), and Perl has more potential
for a prettier shortcut Node API than Java.
I'm mostly interested in making a nice Node-centric API with glue to query
languages, SOAP etc. in Perl (and maybe Python); I guess there are
different API design concerns if you're trying to do a C thing and
maintain Perl, Python, Java etc views of that too.
anyway...
> You'll need to get the content to a local file since redland doesn't
> do URI retrieval; but there are Perl modules for that. In which
yup, LWP::Simple works for me
> case, change the
> my $stream=$parser->parse_as_stream($uri,$uri);
> to
> my $stream=$parser->parse_as_stream($uri,$base_uri);
> where $uri is the URI of the local file and $base_uri is the remote URI.
>
> However, the above doesn't generate N-Triples output.
Shouldn't be too hard...
> > .. I had a quick stab at compiling
> > http://www.redland.opensource.ac.uk/raptor/rdfdump.c but was put off by
> > all the autoconf stuff. BTW you ship an rdfdump.c in the repat directory
> > too (Jason's), which I found a little confusing.
>
> Imagination failed me in naming there. rdfparse?
> Not too tricky to build:
>
> ./configure
> make rdfdump
> ./rdfdump -o ntriples file:local-file baseURI
>
> again, you'll need to get the baseURI content into local-file.
Didn't realise it was setup for your rdfdump.c already. Or do you mean the
replat one? (see, easily confused). The repat one built OK but is seg
faulting for some reason...
Dan
>
> > In general, I reckon it'd be hand for all RDF parsers to be callable on
> > the commandline via some agreed conventions, outputting ntriples. To date
> > I've mostly used Eric P's Perl one, but now I find I need to parse/load
> > 16Mb of RDF annotations it is time to shift to a C parser...
>
> Dave
More information about the redland-dev
mailing list