[redland] perl or commandline interface to raptor?
Dave Beckett
dave.beckett at bristol.ac.uk
Wed Nov 21 22:11:09 GMT 2001
>>>Dan Brickley said:
>
> Dave,
>
> I'm trying to plug Raptor (via Redland Perl or commandline ntriple output)
> into some Perl stuff I'm working on. Any chance of a quick HOWTO for
> getting triples back from URI or chunk-of-markup input, eg. via the Perl
> interface or commandline?
The distribution perl/example.pl code can be cut down to do this.
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;
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
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.
> .. 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.
> 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