RDFLib/rdflib — Issue #85: rdflib Graph parse() fails for nt files with @prefixes
Author: gjhiggins
Created: 2012-02-20 08:32:20+00:00
State: closed

olyerick...@gmail.com, 2009-11-09T15:22:09.000Z

What steps will reproduce the problem?
1. Attempt to parse file example...
http://www.w3.org/2000/10/swap/doc/formats

What is the expected output? What do you see instead?
When I execute...

>>>> g.parse("demo.nt", format="nt")

I except to see something like...
)>

Instead I see...
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-i686/egg/rdflib/Graph.py", line 713, in parse
File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/NTParser.py", line
23, in parse
File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/ntriples.py", line
125, in parse
rdflib.syntax.parsers.ntriples.ParseError: Invalid line: '@prefix :
.'

If I use the "standard form" (NO @prefixes) I get the expected result,
)>

What version of the product are you using? On what operating system?
rdflib-2.4.2 on Ubuntu 9.10

Please provide any additional information below.
I have done numerous tests with sample data; problem is limited to NT
format that includes @prefix lines...

Comment 1 by eik...@gmail.com

Comment 2 by eik...@gmail.com

Comment 3 by drewpca
A file with @prefix isn't in the 'nt' format, which is a very restricted line-based
format for RDF. Your file has a confusing extension, and I confirm that the source
page is being misleading by showing "N-Triples with @prefix".

I added a note about this in the rdflib parser class:

% pydoc rdflib.syntax.parsers.NTParser

class NTParser(rdflib.syntax.parsers.Parser)
| parser for the ntriples format, often stored with the .nt extension
|
| See http://www.w3.org/TR/rdf-testcases/#ntriples
|

http://code.google.com/p/rdflib/source/detail?r=1735