Мой my_data.nt
файл выглядит следующим образом:
<bob> <name> "Robert" .
<bob> <knows> <amy> .
Я использую этот код для его анализа:
from rdflib import Graph
g = Graph()
g.parse("my_data.nt", format="nt")
for ele in g:
print(ele)
Я получаю эту ошибку:
Traceback (most recent call last):
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/ntriples.py", line 140, in parse
self.parseline()
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/ntriples.py", line 189, in parseline
subject = self.subject()
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/ntriples.py", line 216, in subject
subj = self.uriref() or self.nodeid()
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/ntriples.py", line 235, in uriref
uri = self.eat(r_uriref).group(1)
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/ntriples.py", line 210, in eat
raise ParseError("Failed to eat %s at %s" % (pattern.pattern, self.line))
rdflib.plugins.parsers.ntriples.ParseError: Failed to eat <([^:]+:[^\s"<>]+)> at <bob> <name> "Robert" .
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_query.py", line 5, in <module>
g.parse("my_data.nt", format="nt")
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/graph.py", line 1043, in parse
parser.parse(source, self, **args)
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/nt.py", line 26, in parse
parser.parse(f)
File "/Users/x/MyVirtualEnvs/new_python3_env/lib/python3.7/site-packages/rdflib/plugins/parsers/ntriples.py", line 142, in parse
raise ParseError("Invalid line: %r" % self.line)
rdflib.plugins.parsers.ntriples.ParseError: Invalid line: '<bob> <name> "Robert" .'
Чего мне не хватает?
Когда я пробую содержимое my_data.nt
на easyrdf , оно выглядит отлично.