如何从推断类中获取个体属性的子集

时间:2015-02-16 22:04:20

标签: class properties rdf owl inference

在下面的示例中,类在此处输入代码:Class3和:Class4由OWL推理器(例如Pellet)推断为个体的类型:Ind1:

@prefix : <http://www.semanticweb.org/test/2015/1/ontology#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/test/2015/1/ontology> .

<http://www.semanticweb.org/test/2015/1/ontology> rdf:type owl:Ontology .

:Prop1 rdf:type owl:DatatypeProperty .
:Prop2 rdf:type owl:DatatypeProperty .
:Prop3 rdf:type owl:DatatypeProperty .

:Class1 rdf:type owl:Class ;
        owl:equivalentClass [ rdf:type owl:Restriction ;
                              owl:onProperty :Prop1 ;
                              owl:someValuesFrom xsd:string
                            ] .

:Class2 rdf:type owl:Class ;
        owl:equivalentClass [ rdf:type owl:Restriction ;
                              owl:onProperty :Prop2 ;
                              owl:someValuesFrom xsd:string
                            ] .

:Class3 rdf:type owl:Class ;
        owl:equivalentClass [ rdf:type owl:Restriction ;
                              owl:onProperty :Prop3 ;
                              owl:someValuesFrom xsd:string
                            ] .

:Class4 rdf:type owl:Class ;
        owl:equivalentClass [ rdf:type owl:Class ;
                              owl:intersectionOf ( :Class1
                                                   :Class2
                                                 )
                            ] .

:Class5 rdf:type owl:Class ;
        owl:equivalentClass [ rdf:type owl:Class ;
                              owl:unionOf ( :Class3
                                            :Class4
                                          )
                            ] .

:Ind1 rdf:type owl:NamedIndividual ;
      :Prop2 "prop2" ;
      :Prop1 "prop1" ;
      :Prop3 "prop3" .

:Class4,例如由推理器根据属性推断:Prop1和:Ind1的Prop2。

我需要构建一个类型为:Class4的个体:Ind1,类似这样:

:Ind_Class4 rdf:type :Class4
:Ind_Class4 :Prop1 "Prop1"
:Ind_Class4 :Prop2 "Prop2"

我正在寻找如何选择属性:Prop1和:Ind1:Ind1作为类的属性:Class4。

我尝试过SPARQL查询

select * where {
    ?s rdf:type :Class4 .
    ?s ?p ?o .
}

但它返回所有属性:Ind1 - :Prop1,:Prop2和:Prop3:

:Ind1 :Prop1 "Prop1"
:Ind1 :Prop2 "Prop2"
:Ind1 :Prop3 "Prop3"

如果我按照Answer1中的建议改变本体:

:Prop1 rdf:type owl:DatatypeProperty ;
   rdfs:domain :Class1 .

:Prop2 rdf:type owl:DatatypeProperty ;
   rdfs:domain :Class2 .

:Prop3 rdf:type owl:DatatypeProperty ;
   rdfs:domain :Class3 .

:Class1 rdf:type owl:Class .
:Class2 rdf:type owl:Class .
:Class3 rdf:type owl:Class .

:Class4 rdf:type owl:Class ;
    owl:equivalentClass [ rdf:type owl:Class ;
                          owl:intersectionOf ( :Class1
                                               :Class2
                                             )
                        ] .

:Class5 rdf:type owl:Class ;
    owl:equivalentClass [ rdf:type owl:Class ;
                          owl:unionOf ( :Class3
                                        :Class4
                                      )
                        ] .

:Ind1 rdf:type owl:NamedIndividual ;
  :Prop1 "Prop1" ;
  :Prop3 "Prop3" ;
  :Prop2 "Prop2" .

然后建议的SPARQL查询

select * where {
    ?p rdfs:domain :Class4 .
    ?s ?p ?o .
}

返回一个空的结果集。

感谢。

1 个答案:

答案 0 :(得分:2)

由于属性并不属于OWL中的课程,因此并不完全清楚您所要求的内容。相反,属性可以有域;当属性P具有域D时,这意味着只要存在三个 x P y ,就可以推断 x rdf:type D 。现在,您可以要求属性的属性和值,其中属性的域是某个特定类。也就是说,您可以执行以下操作:

select ?property ?value where {
  ?property rdfs:domain :Class4 .
  :individual ?property ?value .
}

但是,请注意一个警告:属性没有单个域,如果您使用推理,他们通常会有很多。请记住,&#34; p&#39;域名是D&#34;表示(在OWL中)&#34; x p y表示x rdf:类型D。&#34;假设你有一个A类和它的子类B.假设属性P的域是B.这意味着每当 xpy 时,我们就有 x rdf:B型。但是,由于B是A的子类,这意味着它也是 x rdf:type A 的情况。这意味着 x p y 也意味着 x rdf:类型A 。反过来,这意味着A也是P的域。我指出这一点,因为这意味着当你问

select ?property ?value where {
  ?property rdfs:domain :Class4 .
  :individual ?property ?value .
}

您还将获得任何具有声明域的属性,该域是Class4的子类

相关问题