我创建了一个本体,现在我想用rdflib来阅读它。问题是如何在不手动检查本体的情况下获得加载图形的URI(名称空间)或前缀,如下所示:
from rdflib import *
rdf_address="C:/Users/eh/ontologies/RNO_V5042/NVDB_RNO_V5042_RDF.owl"
g=Graph()
g.parse(rdf_address)
for namespace in g.namespaces():
print namespace
rno = Namespace("http://www.semanticweb.org/eh/ontologies/2015/3/RNO_V5042#") ###### **how to find this namespace?**
aClass = rno.Node
roundabout= rno.Roundabout
namedIndividual = URIRef('http://www.w3.org/2002/07/owl#NamedIndividual')
rdftype = URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
for triple in g.triples((None,rdftype,rno.Roundabout)):
print triple
目前没有回答
相关问题 更多 >
编程相关推荐