rdf findall error: setup_call_catcher_cleaner

25 views
Skip to first unread message

Richard de Rozario

unread,
Dec 17, 2015, 8:56:59 PM12/17/15
to SWI-Prolog
I get the following error after trying a bagof (or findall) on rdf triples where the triple predicate has a namespace prefix:

ERROR: rdf_db:rdf/3: Type error: `atom' expected, found `foo:rating' (a compound)
^  Exception: (12) setup_call_catcher_cleanup('$bags':'$new_findall_bag', '$bags':findall_loop(_G413, user:rdf(test, foo:rating, _G413), _G342, []), _G481, '$bags':'$destroy_findall_bag') ?

The following example generates this error.

% small rdf program that generates error on bagof
:- use_module(library(semweb/rdf_db)).
:- use_module(library(semweb/rdfs)).
:- rdf_register_prefix(foo,'http://www.foo.org/rdf#',[keep(true)]).


rate(Page,User,Rate):-
  rdf_bnode(B),
  rdf_assert(B,rdfs:member,rdf:'Bag'),
  rdf_assert(Page,foo:rating,B),
  rdf_assert(B,foo:by,User),
  rdf_assert(B,foo:rated,literal(type(integer,Rate))),
  !.

rdfnodes(Sub,Pred,Bags):-
  bagof(B,rdf(Sub,Pred,B),Bags),
  !.

:- rate(test,john,50), rate(test,jane,60).
:- rdfnodes(test,foo:rating,Bags).


The same program without the "foo" prefixes works fine.  Also, doing the bagoff call from the REPL prompt works fine.

Any ideas on how to fix this?

Richard de Rozario

unread,
Dec 17, 2015, 9:21:16 PM12/17/15
to SWI-Prolog
After some further exploring... adding the following as a declaration seems to fix the problem:

:- rdf_meta rdfnodes(r,r,-).

Reply all
Reply to author
Forward
0 new messages