SWI-Prolog / packages-semweb

The SWI-Prolog RDF store
29 stars 15 forks source link

Issue with blank node graph labels for package semweb/turtle #110

Closed josd closed 7 months ago

josd commented 7 months ago

In RDF 1.1 TriG RDF Dataset Language W3C Recommendation 25 February 2014 graph labels can be blank nodes but rdf_read_turtle/3 gives Syntax error: PN_PREFIX expected. So

$ cat test.trig
@prefix : <urn:example:>.

:x {
    :s :p :o.
}

works fine

$ swipl -q
?- use_module(library(semweb/turtle)).
true.

?- open('test.trig', read, In, []), rdf_read_turtle(stream(In), T, [format(trig)]).
In = <stream>(0x561ed17b1200),
T = [rdf('urn:example:s', 'urn:example:p', 'urn:example:o', 'urn:example:x':4)].

?-

but

$ cat test.trig
@prefix : <urn:example:>.

_:x {
    :s :p :o.
}

gives an error

$ swipl -q
?- use_module(library(semweb/turtle)).
true.

?- open('test.trig', read, In, []), rdf_read_turtle(stream(In), T, [format(trig)]).
ERROR: test.trig:3:4: Syntax error: PN_PREFIX expected
In = <stream>(0x560970edb200),
T = [].

?-

PS what is the :4 meaning in the 4th quad position 'urn:example:x':4?

JanWielemaker commented 7 months ago

PS what is the :4 meaning in the 4th quad position 'urn:example:x':4?

The line number. That is how traditionally the SWI-Prolog RDF db 4th argument works: all triples are associated with a graph that is the file and the line number. Possibly we should add an option that allows hiding these.

josd commented 7 months ago

Thanks Jan and now the eye --trig <uri> works as expected 👍