walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

rdflib Graph parse() fails for nt files with @prefixes #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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...
<Graph identifier=xxxxxxxxx (<class 'rdflib.graph.Graph'>)>

Instead I see...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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 :
<http://www.w3.org/2000/10/swap/test/demo1/about-pat#> .'

If I use the "standard form" (NO @prefixes) I get the expected result, 
<Graph identifier=ZUbKkMRk0 (<class 'rdflib.Graph.Graph'>)>

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...

Original issue reported on code.google.com by olyerick...@gmail.com on 9 Nov 2009 at 3:22

GoogleCodeExporter commented 8 years ago

Original comment by eik...@gmail.com on 1 Feb 2010 at 7:27

GoogleCodeExporter commented 8 years ago

Original comment by eik...@gmail.com on 1 Feb 2010 at 8:02

GoogleCodeExporter commented 8 years ago
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

Original comment by drewpca on 2 Feb 2010 at 3:59