Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Class 如何从推断类中获取单个属性的子集_Class_Properties_Rdf_Owl_Inference - Fatal编程技术网

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

Class 如何从推断类中获取单个属性的子集,class,properties,rdf,owl,inference,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#>

在以下示例中,类在此处输入代码: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" .
我正在研究如何选择:Ind1的属性:Prop1和:Prop2作为类:Class4的属性

我尝试了SPARQL查询

select * where {
    ?s rdf:type :Class4 .
    ?s ?p ?o .
}
select * where {
    ?p rdfs:domain :Class4 .
    ?s ?p ?o .
}
但它返回:Ind1-:Prop1、:Prop2和:Prop3的所有属性:

:Ind1 :Prop1 "Prop1"
:Ind1 :Prop2 "Prop2"
:Ind1 :Prop3 "Prop3"
如果我按照回答1中的建议更改本体:

: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 {
    ?s rdf:type :Class4 .
    ?s ?p ?o .
}
select * where {
    ?p rdfs:domain :Class4 .
    ?s ?p ?o .
}
返回一个空的结果集


谢谢。

由于属性不属于OWL中的类,所以您的问题并不完全清楚。相反,属性可以有域;当属性P具有域D时,这意味着任何时候都有三个xpy,您可以推断xrdf:type D。现在,您可以询问某个个人的属性和值,其中属性的域是某个特定的类。也就是说,你可以这样做:

选择属性值,其中{
?属性rdfs:域:Class4。
:单个?属性?值。
}
然而,请注意一个警告:属性没有单一的域,如果您使用推理,它们通常会有很多。记住,“p的域是D”意味着(在OWL中)“x p y意味着x rdf:类型D”。假设你有一个类a和它的一个子类B。假设一个属性p的域是B。这意味着无论何时x p y,我们都有x rdf:类型B。但是,由于B是a的一个子类,这意味着xrdf:typea也是这样。这意味着xpy也意味着xrdf:type A。这反过来意味着A也是P的一个域。我指出这一点,因为这意味着当你问

选择属性值,其中{
?属性rdfs:域:Class4。
:单个?属性?值。
}

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

类Class1(例如)应定义一个提供属性Prop1的个人类。class Class4应该定义提供class Class1属性Prop1和class Class2属性Prop2的个人类。@igor.br我不确定您想说什么。您可以通过说出类似于
PetOwner equivalentClass(hasPet some Thing)
之类的话来定义属性具有某种价值的事物类,但我不确定您是否想这么说。推理器在Protege中显示Class4作为提供属性Prop1和Prop2的单个Ind1类型。我需要找出如何从Model/Graph(我使用的是Jena)或SPARQL中获得这些信息。将类Class1和Class2的定义从属性限制更改为属性域不会带来成功。您建议的SPARQL不会返回任何结果。@igor.br我仍然不清楚问题到底是什么。你能更新这个问题以显示你想要的结果吗。如果这一次你必须手工创建它们,那也没关系;我们将更好地理解您试图获取的内容。我用预期的结果扩展了原始问题,并使用本体定义属性域。