所以我有一个看起来像这样的 Notation3 文件:
@prefix wn: <http://www.w3.org/2006/03/wn/wn20/instances/> .
@prefix lemon: <http://www.monnet-project.eu/#> .
@prefix lexinfo: <http://www.lexinfo.net/ontology#> .
:lexicon a lemon:Lexicon ;
lemon:language "it" ;
lemon:entry :fifa.
:fifa a lemon:LexicalEntry ;
lemon:canonicalForm [ lemon:writtenRep "fifa"@it ] ;
lemon:sense [ lemon:reference wn:synset-fear-noun-1 ];
lexinfo:partOfSpeech lexinfo:noun .
我正在尝试将其输入到 RDFlib Graph 中并使用以下代码将其序列化为 RDFxml 文件:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import rdflib
from rdflib import URIRef, Graph, Namespace
from rdflib.plugins.parsers.notation3 import N3Parser
g = Graph()
result = g.parse(file=open("lemon_example_fear.txt", "r"), format="text/n3")
print (g.serialize(format='xml'))
但目前我收到此错误:
rdflib.plugins.parsers.notation3.BadSyntax: at line 5 of <>:
Bad syntax (Prefix ":" not bound) at ^ in:
"... lexinfo: <http://www.lexinfo.net/ontology/2.0/lexinfo#> .
^:lexicon a lemon:Lexicon ;
lemon:language "it" ;
lem..."
这是我尝试序列化的文件还是我用来执行序列化的代码的问题?