【发布时间】:2019-11-26 20:08:23
【问题描述】:
所以我有一个我在 Protege 中构建的本体,它有注释和子注释。我的意思是,一个概念可能有一个定义,而这个定义可能有注释。
所以你可能有类似 (s,p,o):
'http://purl.fakeiri.org/ONTO/1111' --> 'label' --> 'Term'
'Term' --> 'comment' --> 'Comment about term.'
我正在尝试使用 Flask 应用程序使本体易于探索(我正在使用 Python 来解析本体文件),但我似乎无法快速获取所有注释和子注释。
我开始使用 owlready2 包,但它要求您自定义每个单独的注释属性(您不能只获取所有注释属性的列表,所以如果您添加像 random_identifier 这样的属性,您必须返回代码并添加entity.random_identifier 否则将不会被拾取)。这行得通,速度很快,但子注释需要加载 IRI,然后搜索它:
random_prop = IRIS['http://schema.org/fillerName']
sub_annotation = x[entity, random_prop, annotation_label]
这非常慢,加载搜索大约 140 种子注释类型需要 5-10 分钟,而仅注释大约需要 3-5 秒。
从那里我决定放弃owlready2 并尝试rdflib。但是,看起来子注释只是作为 BNode 附加的,我不知道如何通过它们的“父”注释访问它们,或者是否有可能。
TL;DR:有人知道如何访问一个条目并在 XML/RDF 本体文件中快速收集其所有注释和子注释吗?
编辑 1:
按照建议,这是本体的 sn-p:
<!-- http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42610 -->
<owl:Class rdf:about="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42610">
<rdfs:subClassOf rdf:resource="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42698"/>
<obo:IAO_0000115 xml:lang="en">A shortened form of a word or phrase.</obo:IAO_0000115>
<oboInOwl:hasDbXref rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://en.wikipedia.org/wiki/Abbreviation</oboInOwl:hasDbXref>
<rdfs:label xml:lang="en">abbreviation</rdfs:label>
<schema:alternateName xml:lang="en">abbreviations</schema:alternateName>
<Property:P1036 rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">411</Property:P1036>
</owl:Class>
<owl:Axiom>
<owl:annotatedSource rdf:resource="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C42610"/>
<owl:annotatedProperty rdf:resource="https://www.wikidata.org/wiki/Property:P1036"/>
<owl:annotatedTarget rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">411</owl:annotatedTarget>
<schema:bookEdition rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">20</schema:bookEdition>
</owl:Axiom>
非常感谢大家!
【问题讨论】:
-
你能从Protege生成的本体中添加一个sn-p,显示注释和子注释吗? OWL定义了IRI或匿名个体上的注解,公理上的注解和嵌套注解,即注解上的注解,但没有特定于注解值上的注解(如果注解值是IRI或匿名个体,它可以被注解,但这很简单一个单独的注释公理。根据您所追求的,不同的 API 可能具有非常不同的数据访问方式 - SPARQL 查询也会有所不同。
-
@Ignazio 我完全没想到,非常感谢!我在上面加了。看起来它直接在类之后将源、属性和目标注释为公理。
标签: xml python-3.6 rdf ontology rdflib