tags:

views:

19

answers:

1

Hi,

I have a rdf file (file.trp) in n-triples format, where each line is a well-formed triple:

"subject predicate object ."

I tried to use rdf_load in semweb/rdf_db to load it into memory, but failed. Here is what I tried:

?- rdf_load('file.trp').

?- rdf_load('file.trp', [format(triples)]).

The trace shows that the goal fails at:

rdf_db:rdf_load_stream/3

which calls

rdf_load_db_/3

which is probably defined in a foreign library.

the manual says it supports xml and triples. But it only loads rdf xml files. How can I load such rdf triple file?

Thanks, Li

A: 

The manual suggests that the predicate rdf_load/2 supports either the RDF/XML or, it's 'internal quick load and cache format', which is probably not the n-triples format.

Firstly, you'll need to import the following to make use of this predicate anyhow:

:- use_module(library(semweb/rdf_db)).

Secondly, I think you'll need to convert your triples into an appropriate format which is readable by this predicate, such as RDF/XML, and use the call like this:

 rdf_load('file.xml', [format(xml)]).

You can use this online converter for converting between n-triples and RDF/XML format (amongst others).

sharky