1

使用 Protege 和 SWRL 选项卡,我有下面提到的本体。它由班级Test和班级组成Shadow,其中Test有三个人t1, t2, t3。我试图定义一个 SWRL 规则,Shadow为 的每个现有个体创建一个类个体Test,该规则是

Test(?x) ^ swrlx:makeOWLThing(?new, ?x) -> Shadow(?new)

问题:

  1. Shadow只创建了, named的一个个体fred,而不是三个(对应于t1, t2, t3)。
  2. 如何控制始终命名的结果个体的命名fred

    Prefix(:=<http://www.semanticweb.org/hilal/ontologies/2016/5/untitled-    ontology-58#>)
    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#>)                
    Ontology(<http://www.semanticweb.org/hilal/ontologies/2016/5/untitled- ontology-58>
    
    Declaration(Class(:Shadow))
    Declaration(Class(:Test))
    Declaration(NamedIndividual(:t1))
    Declaration(NamedIndividual(:t2))
    Declaration(NamedIndividual(:t3))
    Declaration(AnnotationProperty(<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled>))
    
    
    
    ############################
    #   Named Individuals
    ############################
    
    # Individual: :t1 (:t1)
    
    ClassAssertion(:Test :t1)
    
    # Individual: :t2 (:t2)
    
    ClassAssertion(:Test :t2)
    
    # Individual: :t3 (:t3)
    
    ClassAssertion(:Test :t3)
    
    
    DLSafeRule(Annotation(<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> "true"^^xsd:boolean) Annotation(rdfs:comment ""^^xsd:string) Annotation(rdfs:label "S1"^^xsd:string) Body(BuiltInAtom(<http://swrl.stanford.edu/ontologies/built-ins/3.3/swrlx.owl#makeOWLThing> Variable(<new>) Variable(<x>)) ClassAtom(:Test Variable(<x>)))Head(ClassAtom(:Shadow Variable(<new>))))
    )
    
4

2 回答 2

0

据我了解 DL 安全条件,SWRL 规则不能创建新个体。

于 2016-06-26T13:36:54.850 回答
0

在评论中,您链接到描述该扩展的语义的文章:

我实现的第一个内置插件之一提供了以受控方式创建新个体的能力。[2] 中有详细的解释,但基本上一个名为 swrlx:makeOWLThing 的内置函数会创建一个新个体并将其绑定到其第一个未绑定参数;为剩余参数的每个独特模式创建一个新个体。

现在,让我们看一下问题中写的规则:

测试(?x) ^​​ swrlx:makeOWLThing(?new, ?x) -> 阴影(?new)

如果原子是从左到右处理的,那么 ?x 应该在遇到 makeOWLThing 时被绑定,但 ?new 不是。这意味着你应该得到一个绑定到变量 ?new 的新个体,并且对于每个 ?x 值,你应该得到一个不同的 ?new 值。这就是你想要的。但是,在您发布的代码中,我看到了这一点:

DLSafeRule(
  Annotation(<http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> "true"^^xsd:boolean)
  Annotation(rdfs:comment ""^^xsd:string)
  Annotation(rdfs:label "S1"^^xsd:string)

  Body(
    BuiltInAtom(<http://swrl.stanford.edu/ontologies/built-ins/3.3/swrlx.owl#makeOWLThing>
      Variable(<new>)
      Variable(<x>))
    ClassAtom(:Test Variable(<x>)))

  Head(
    ClassAtom(:Shadow Variable(<new>))))
)

我不确定,但如果也是从左到右处理的,那么makeOWLThing(?new,?x)会首先出现,在这种情况下, ?x 在创建新个体时将不受约束,所以你只会得到一个新的个体。

于 2016-06-27T15:42:16.250 回答