Re: Prolog Ntriples Query Problem

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 01/03/2014 08:09 AM, atom meta wrote:
> Hello,
> 
> 
> I am trying to query an Ntriples file (.nt) on Prolog using the following
> code. It seems that I can load the data and consult it successfully.
> 
> But a problem occurs when I query the triples like rdf(X,Y,Z). It shows
> some kind of strange error saying that " Correct to: "rdf_db:rdf(X,Y,Z)"? ".
> 
> 
> PROLOG CODE:
> 
> 
> :- use_module(library(semweb/rdf_ntriples)).
> 
> rdf_load('schema-full.nt').

This _defines_ the predicate rdf_load/1.  If you want to _call_ something,
you normally define a predicate for this or you use the initialization
_directive_.  Thus:

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

load_schema :-
	rdf_load('schema-full.nt').

And then in the command line:

	?- load_schema.
	<some message telling how many triples it loaded>
	true.

	?- rdf(S,P,O).
	S = ...

Or (in a file):

:- use_module(library(semweb/rdf_db)).
:- use_module(library(semweb/rdf_ntriples)).
:- initialization rdf_load('schema-full.nt').

Hope this helps.  You probably want to read `getting started'
(http://swi-prolog.org/pldoc/man?section=quickstart) and possibly
some beginners book or online tutorial.

	Success --- Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.