Re: puzzlement over prefix expansion
Wouter Beek <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAE1un7MK4f6Zy7Mg6nY-D0iVx_Gs9ZGAvnwHLQ-ow4roPghDZQ@mail.gmail.com> |
Hi Anne,
Notice that
test:- test(flo:outputFor).
:- rdf_meta(test(r)).
test(X):- write(X).
outputs
flo:outputFor
but
:- rdf_meta(test(r)).
test:- test(flo:outputFor).
test(X):- write(X).
outputs
http://www.friendularity.org/ontology/flo#outputFor
plDoc mentions this: "The directive must be processed before the definition
of the predicates *as well as before compiling code that uses the rdf
meta-predicates*."
PS: Is there any difference between using `r`, and `t` in `rdf_meta/1`? I
always use `r`, am I missing some nice functionality because of that / are
their interesting use-cases for `t`? (I believe `o` has a use-case for
resolving prefix notation in the type IRI of typed literals, which are
compound terms, so that one's clearly useful.)
---
Cheers!,
Wouter.
E-mail: [email protected]
WWW: www.wouterbeek.com
Tel.: 0647674624
On Tue, Sep 3, 2013 at 7:38 AM, Anne Ogborn <[email protected]> wrote:
> I'm having trouble understanding rdf prefix expansion.
>
> Below is a mass-o-code. According to my feeble mind's understanding it
> should work, but
> it doesn't, so obviously I'm autobogotified.
>
> Forgive the length, but I figured better that than missing something
> relevant.
>
> I'm trying to generate a turtle file that represents some info I already
> have as prolog facts
> (thats whats in floblocks). I'm having trouble with rdf_meta not working
> properly - querying
> convert('test.ttl').
> results in it running down to the error, where it throws an error,
> expecting an atom and getting
> flo:inputFor
> which is apparently ':'(flo, inputFor)
>
> Note that it's obviously the rdf_meta being ignored somehow, since items
> in add_rdf are being converted properly.
> changing one of the r's in the rdf_meta to rdf generates an error, so
> apparently the rdf_meta declaration is indeed being
> interpreted somehow.
>
> :- module(converter, [convert/1]).
> /** <module> Non automagic code for making the rdf
>
> */
> :- use_module(floblocks).
>
> :- use_module(library(semweb/rdf_db)).
> :- use_module(library(semweb/rdf_turtle_write)).
> :- use_module(library(semweb/rdfs)).
>
> :- rdf_register_prefix(flo, 'http://www.friendularity.org/ontology/flo#').
>
>
> convert(Outfile) :-
> setof(BlockType, Section^section(BlockType, Section), BlockTypes),
> add_rdf(BlockTypes),
> write_rdf(Outfile).
>
> add_rdf([]).
> add_rdf([H|T]) :-
> rdf_global_id(flo:H, HGlobal),
> rdf_assert(HGlobal, rdf:type, flo:'BlockType'),
> subsection(H, SubSection),
> rdf_assert(HGlobal, flo:subsection, literal(SubSection)),
> section(H, Section),
> rdf_assert(HGlobal, flo:section, literal(Section)),
> description(H, Desc),
> rdf_assert(HGlobal, rdfs:comment, literal(Desc)),
> rdf_assert(HGlobal, rdfs:label, literal(H)),
> visual_style(H, Style),
> rdf_assert(HGlobal, flo:visual_style, literal(Style)),
> inputs(H, InputList),
> input_types(H, InputTypeList),
> % call is here
> assert_rdf_list(HGlobal, flo:inputFor, flo:inputName, InputList,
> flo:inputType, InputTypeList),
> outputs(H, OutputList),
> output_types(H, OutputTypeList),
> assert_rdf_list(HGlobal, flo:outputFor,
> flo:outputName, OutputList,
> flo:outputType, OutputTypeList),
>
> add_rdf(T).
>
> :- rdf_meta assert_rdf_list(o, r, r, +, r, +).
>
> assert_rdf_list(_, _, _, [], _, _).
> assert_rdf_list(Subj, PredLinkingSubj, Type1, [required(H1)|T1], Type2,
> [H2|T2]) :- !,
> rdf_bnode(BNode),
> % Yells that PredLinkingSubj is flo:inputFor, isn't an atom here <===
> THE ERROR
> rdf_assert(BNode, PredLinkingSubj, Subj),
> rdf_assert(BNode, Type1, literal(H1)),
> rdf_assert(BNode, Type2, literal(H2)),
> rdf_assert(Subj, flo:requiresInput, BNode),
> assert_rdf_list(Subj, PredLinkingSubj, Type1, T1, Type2, T2).
> assert_rdf_list(Subj, PredLinkingSubj, Type1, [optional(H1)|T1], Type2,
> [H2|T2]) :- !,
> rdf_bnode(BNode),
> rdf_assert(BNode, PredLinkingSubj, Subj),
> rdf_assert(BNode, Type1, literal(H1)),
> rdf_assert(BNode, Type2, literal(H2)),
> rdf_assert(Subj, flo:optionalInput, BNode),
> assert_rdf_list(Subj, PredLinkingSubj, Type1, T1, Type2, T2).
> assert_rdf_list(Subj, PredLinkingSubj, Type1, [H1|T1], Type2, [H2|T2]) :-
> rdf_bnode(BNode),
> rdf_assert(BNode, PredLinkingSubj, Subj),
> rdf_assert(BNode, Type1, literal(H1)),
> rdf_assert(BNode, Type2, literal(H2)),
> rdf_assert(Subj, flo:optionalInput, BNode),
> assert_rdf_list(Subj, PredLinkingSubj, Type1, T1, Type2, T2).
>
>
> write_rdf(Outfile) :-
> rdf_save_turtle(Outfile, []).
>
>
> A vastly puzzled noobie-to-semweb Annie bangs head against desk
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
>
-------------- next part --------------
HTML attachment scrubbed and removed