gpt4 book ai didi

java - 查询所有 "AnnotationAssertions"的类(class)/个人

转载 作者:行者123 更新时间:2023-12-02 05:19:00 27 4
gpt4 key购买 nike

我正在尝试查询与类/个人相关的所有 AnnotationAssertion。

下面是我的来源片段:

        <AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:comment"/>
<IRI>#Car</IRI>
<Literal xml:lang="en" datatypeIRI="&rdf;PlainLiteral">A car has four tyres</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty IRI="http://www.w3.org/2004/02/skos/core#definition"/>
<IRI>#car</IRI>
<Literal xml:lang="en" datatypeIRI="&rdf;PlainLiteral">a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people.</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty IRI="http://www.w3.org/2004/02/skos/core#example"/>
<IRI>#car</IRI>
<Literal xml:lang="en" datatypeIRI="&rdf;PlainLiteral">Audi</Literal>
</AnnotationAssertion>
etc..

我正在尝试查询与此类/个体关联的 AnnotationProperties 及其 AnnotationAssertions 列表。

SPARQL-DL API提供通过

查询注释属性的可能性
Annotation(a, b, c)

任何查询 AnnotationAssertions 的指针都会非常有帮助。

最佳答案

您在问题中提到了 SPARQL-DL,但这也被标记为 ,并且简单的 SPARQL 中的答案并不太复杂。这将类似于:

prefix  owl: <http://www.w3.org/2002/07/owl#>

select ?s ?p ?o where {
?s ?p ?o .
?p a owl:AnnotationProperty .
}

但是,您在这里可能遇到的困难是,可能并非每个注释属性都被实际声明。这会让事情变得更加困难,但是您可以通过询问所有三元组来尝试解决这个问题,除了那些属性是已知的 ObjectProperty 或 DatatypeProperty 的三元组,以及那些在 OWL 到 RDF 映射中使用的三元组(以 rdf 开头的属性:或 owl: 和某些 rdfs: 属性)。例如,

prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select ?s ?p ?o where {
?s ?p ?o .

#-- don't include object or datatype properties
filter not exists {
values ?type { owl:ObjectProperty owl:DatatypeProperty }
?p a ?type
}

#-- don't include properties from rdf: or owl: namespaces
filter( !strstarts( str(?p), str(rdf:) ) )
filter( !strstarts( str(?p), str(owl:) ) )

#-- don't include rdfs: properties used in OWL to RDF mapping
filter( ?p not in ( rdfs:range, rdfs:domain, rdfs:subClassOf, rdfs:subPropertyOf ) )
}

关于java - 查询所有 "AnnotationAssertions"的类(class)/个人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26656608/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com