我使用了dbpedia.owl文件,并使用owlready2
库加载了本体。我想知道如何访问rdf:resource
标签下的rdfs:domain
。他们的文档没有任何线索可做。以下显示了当前代码状态。
from owlready2 import *
# ===== Loading dbpedia.owl =========
onto_path.append("../")
onto = get_ontology("dbpedia.owl")
onto.load()
propertyDict = {}
propertiesGen = onto.properties()
for ontoProperty in propertiesGen:
if len(ontoProperty.range) == 0:
print(ontoProperty)
是否有一种像ontoProperty.range.resource
这样的访问方式?但这不起作用。 owl
文件中的以下部分显示了与ontoProperty
的对应关系。
非常感谢您的回答和建议。
<owl:DatatypeProperty rdf:about="http://dbpedia.org/ontology/nationalRanking">
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
<rdfs:label xml:lang="en">national ranking</rdfs:label>
<rdfs:domain rdf:resource="http://dbpedia.org/ontology/EducationalInstitution"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#positiveInteger"/><prov:wasDerivedFrom rdf:resource="http://mappings.dbpedia.org/index.php/OntologyProperty:nationalRanking"/>
</owl:DatatypeProperty>