【发布时间】:2018-03-04 06:41:41
【问题描述】:
我正在尝试在任何推理系统或三重存储提供的加载时验证之外设置一些轻量级的按需数据验证。我正在使用 GraphDB 8.3。
假设我使用 Ontology of Biomedical Investigations (OBI) http://purl.obolibrary.org/obo/obi.owl 加载以下三元组:
PREFIX : <http://example.com/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
insert data {
graph :data
{
:measurement1 a <http://purl.obolibrary.org/obo/IAO_0000032> ;
<http://purl.obolibrary.org/obo/IAO_0000004> "100.1"^^xsd:double .
:measurement2 a <http://purl.obolibrary.org/obo/IAO_0000032> ;
<http://purl.obolibrary.org/obo/IAO_0000004> "100"^^xsd:int .
}
}
这表示:measurement1 和:measurement2 具有测量值。 <http://purl.obolibrary.org/obo/IAO_0000004> 的范围是xsd:double。我知道我可以使用以下查询来检查与指定范围不完全相同的数据类型。
正如您在我的查询中嵌入的 cmets 中看到的那样,我想说 :measurement2 的值 "100"^^xsd:int 是可以接受的,因为所有整数都包含在双精度浮点数集中. (对吧?)
是否存在表明xsd:int 是xsd:double 的子类的现有本体?
PREFIX : <http://example.com/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# loaded obi into http://example.com/ontology
select distinct ?stype ?p ?ptype ?propdom ?proprange ?otype ?odatatype where {
{
graph :data
{
?s ?p ?o .
bind (datatype(?o) as ?odatatype)
}
optional {
graph <http://example.com/ontology> {
values ?ptype {
owl:ObjectProperty owl:DatatypeProperty
}
?p a ?ptype
}
}
optional {
?o a ?otype
}
optional {
?s a ?stype
}
optional {
{
graph <http://example.com/ontology> {
?p rdfs:domain ?propdom
}
}
}
optional {
{
graph <http://example.com/ontology> {
?p rdfs:range ?proprange
}
}
}
}
minus
{
?s rdf:type ?o
}
# minus
# {
# ?odatatype rdfs:subClassOf+ ?proprange
# }
filter ( ?odatatype != ?proprange )
}
【问题讨论】:
-
Long story...
标签: xsd sparql rdf owl graphdb