简体   繁体   English

如何在给定的本体中获得没有定义的rdfs:range的数据类型属性

[英]How to get, in a given ontology, the datatype properties without a defined rdfs:range

I need to check, in a given ontology, by means of an SPARQL query, the datatype properties that does not have rdfs:range defined. 我需要在给定的本体中,通过SPARQL查询来检查未定义rdfs:range的数据类型属性。 For example, in the following code, the result I'm looking for would be dataproperty2 . 例如,在下面的代码中,我正在寻找的结果将是dataproperty2

ont:Class1  a  owl:Class .
ont:Class2  a  owl:Class .

ont:dataProperty1  a  owl:DatatypeProperty ;
rdfs:domain  ont:Class1 ;
rdfs:label   "dataProperty1"@en ;
rdfs:range   xsd:string .

ont:dataProperty2  a  owl:DatatypeProperty ;
rdfs:domain  ont:Class2 ;
rdfs:label   "dataProperty2"@en .

I have defined this SPARQL query that retrieve the number of properties that match with this condition, but since is an aggregated function, ie, COUNT, I'm having problems to get the datatype properties, not the number, that does not have rdfs:range defined. 我已经定义了此SPARQL查询,以检索与此条件匹配的属性的数量,但是由于是聚合函数(即COUNT),因此在获取没有rdfs的数据类型属性而不是数字时遇到了问题:范围已定义。

SELECT ?return WHERE 
{
  {
  SELECT (COUNT(?p) as ?pCount)
    WHERE
    {
      ?p rdf:type owl:DatatypeProperty .
      ?p rdfs:range ?range .
    }
  }
  {
  SELECT DISTINCT (COUNT(?p) as ?prop)
    WHERE
    {
      ?p rdf:type owl:DatatypeProperty .
    }
  }
  BIND((?prop - ?pCount) as ?return) 
}

Just select the datatype properties and then filter out the ones that don't have range properties: 只需选择数据类型属性,然后滤除那些没有范围属性的属性即可:

select ?p where {
  ?p a owl:DatatypeProperty
  filter not exists {
    ?p rdfs:range ?range
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM