简体   繁体   English

Protégé-OWL / SWRL 中的本体属性定义

[英]Ontology property definition in Protégé-OWL / SWRL

I need to implement an OWL-ontology in Protégé, which contains a two classes: s1 and s2 , both are the instances of System class. These two classes are connected by the connection class s1_s2 , which contains property omega .我需要在 Protégé 中实现一个 OWL-ontology,它包含两个类: s1s2 ,它们都是System class 的实例。这两个类通过连接 class s1_s2连接,其中包含属性omega This property has to take a value according to the following law:此属性必须根据以下法则取值:

omega = 1 * s1.complete欧米茄 = 1 * s1.complete

How can I implement it in Protégé in a such way, I could use it in SWRL-rule in the future?我怎样才能以这种方式在 Protégé 中实现它,以便将来在 SWRL-rule 中使用它?

具有类之间连接的类图片段

In general, you'd start by defining the classes and the properties that you need:通常,您将从定义所需的类和属性开始:

类

对象属性

数据类型属性

At this point you could add some axioms that govern how the systems have to interact, how the properties work, etc. Eg, you might declare domains and ranges on your properties.此时您可以添加一些公理来管理系统必须如何交互、属性如何工作等。例如,您可以在属性上声明域和范围。 Here's a domain and range on the hasS2 property:这是hasS2属性的域和范围:

hasS2域和范围

You might also want to say that each InterSystem has exactly one associate S1 and S2 :您可能还想说每个InterSystem都有一个关联的S1S2

hasS1 恰好 1 S1 …

To put in the mathematical constraints, you'll actually need SWRL;要加入数学约束,您实际上需要 SWRL; you won't be able to enforce the constraint using other kinds of OWL axioms.您将无法使用其他类型的 OWL 公理来强制执行约束。 The rule you'd want is along the lines of the following.您想要的规则如下所示。 If you declare domains and ranges on your predicates, then you won't need all the type predicates that appear in this rule, since they could be inferred from the property usage.如果您在谓词上声明域和范围,那么您将不需要此规则中出现的所有类型谓词,因为它们可以从属性用法中推断出来。

S1(?s1) ∧ InterSystem(?i) ∧ hasS1(?i,?s1) ∧ hasComplete(?s1,?complete) multiply(?omega,1,?complete) → hasOmega(?i,?omega) S1(?s1) ∧ InterSystem(?i) ∧ hasS1(?i,?s1) ∧ hasComplete(?s1,?complete) 乘法(?omega,1,?complete) → hasOmega(?i,?omega)

The multiplication here actually seems redundant, since you're multiplying by 1, so omega = alpha, in which case the head of that rule could simply be hasOmega(?i,?alpha) .这里的乘法实际上看起来是多余的,因为你乘以 1,所以 omega = alpha,在这种情况下,该规则的头部可以简单地是hasOmega(?i,?alpha) In Protégé the rule looks like this:在 Protégé 中,规则如下所示:

规则

(In the version of Protégé that I'm using (not the latest), I had to Window > Create New Tab to create a Rules tab, and then Window > Views > Ontology Views > Rules to add the Rules list to the interface.) (在我使用的 Protégé 版本中(不是最新版本),我必须通过 Window > 创建新选项卡来创建规则选项卡,然后通过 Window > 视图 > 本体视图 > 规则将规则列表添加到界面。 )

The Turtle serialization of the RDF representation of this OWL ontology (which you can save and load into Protégé) is:此 OWL 本体的 RDF 表示的 Turtle 序列化(您可以将其保存并加载到 Protégé 中)是:

@prefix :      <http://stackoverflow.com/q/21499126/1281433/systems#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix swrl:  <http://www.w3.org/2003/11/swrl#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<urn:swrl#s1>  a  swrl:Variable .

:hasComplete  a  owl:DatatypeProperty .

[ a          swrl:Imp ;
  swrl:body  [ a          swrl:AtomList ;
               rdf:first  [ a                    swrl:ClassAtom ;
                            swrl:argument1       <urn:swrl#i> ;
                            swrl:classPredicate  :InterSystem
                          ] ;
               rdf:rest   [ a          swrl:AtomList ;
                            rdf:first  [ a                    swrl:ClassAtom ;
                                         swrl:argument1       <urn:swrl#s1> ;
                                         swrl:classPredicate  :S1
                                       ] ;
                            rdf:rest   [ a          swrl:AtomList ;
                                         rdf:first  [ a                       swrl:IndividualPropertyAtom ;
                                                      swrl:argument1          <urn:swrl#i> ;
                                                      swrl:argument2          <urn:swrl#s1> ;
                                                      swrl:propertyPredicate  :hasS1
                                                    ] ;
                                         rdf:rest   [ a          swrl:AtomList ;
                                                      rdf:first  [ a                       swrl:DatavaluedPropertyAtom ;
                                                                   swrl:argument1          <urn:swrl#s1> ;
                                                                   swrl:argument2          <urn:swrl#complete> ;
                                                                   swrl:propertyPredicate  :hasComplete
                                                                 ] ;
                                                      rdf:rest   [ a          swrl:AtomList ;
                                                                   rdf:first  [ a               swrl:BuiltinAtom ;
                                                                                swrl:arguments  [ a          rdf:List ;
                                                                                                  rdf:first  <urn:swrl#omega> ;
                                                                                                  rdf:rest   [ a          rdf:List ;
                                                                                                               rdf:first  1 ;
                                                                                                               rdf:rest   ( <urn:swrl#complete> )
                                                                                                             ]
                                                                                                ] ;
                                                                                swrl:builtin    swrlb:multiply
                                                                              ] ;
                                                                   rdf:rest   ()

                                                                 ]
                                                    ]
                                       ]
                          ]
             ] ;
  swrl:head  [ a          swrl:AtomList ;
               rdf:first  [ a                       swrl:DatavaluedPropertyAtom ;
                            swrl:argument1          <urn:swrl#i> ;
                            swrl:argument2          <urn:swrl#omega> ;
                            swrl:propertyPredicate  :hasOmega
                          ] ;
               rdf:rest   ()

             ]
] .

:S2     a                owl:Class ;
        rdfs:subClassOf  :System .

<urn:swrl#omega>  a  swrl:Variable .

:S1     a                owl:Class ;
        rdfs:subClassOf  :System .

:InterSystem  a          owl:Class ;
        rdfs:subClassOf  [ a                         owl:Restriction ;
                           owl:onClass               :S1 ;
                           owl:onProperty            :hasS1 ;
                           owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                         ] ;
        rdfs:subClassOf  [ a                         owl:Restriction ;
                           owl:onClass               :S2 ;
                           owl:onProperty            :hasS2 ;
                           owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                         ] .

<urn:swrl#complete>  a  swrl:Variable .

<http://stackoverflow.com/q/21499126/1281433/systems>
        a       owl:Ontology .

:hasS2  a       owl:ObjectProperty .

:hasOmega  a    owl:DatatypeProperty .

:System  a      owl:Class .

:hasS1  a       owl:ObjectProperty .

<urn:swrl#i>  a  swrl:Variable .

That's a good start, but it's worthwhile to see how it all works.这是一个好的开始,但值得看看它是如何工作的。 To see a place where the rules could be applied, we'll need some instance data and a reasoner.要查看可以应用规则的地方,我们需要一些实例数据和推理器。 You mentioned that you can use Pellet from within Protégé, so we're all set on that count.你提到你可以在 Protégé 中使用 Pellet,所以我们都准备好了。 For some instance data, let's create and InterSystem , its S1 , and assign the S1 's complete value.对于某些实例数据,让我们创建InterSystem及其S1并分配S1的完整值。

系统间

s1

You'll need to select the Pellet reasoner from the Reasoner menu, and then select Reasoner > Start Reasoner.您需要从 Reasoner 菜单中选择 select Pellet reasoner,然后选择 select Reasoner > Start Reasoner。 At this point, you could run a DL query for “hasOmega value 42” to confirm that the individual has the desired property (make sure that you check the “Individuals” checkbox on the right):此时,您可以针对“hasOmega value 42”运行 DL 查询,以确认个人具有所需的属性(确保选中右侧的“Individuals”复选框):

在此处输入图像描述

If you navigate to the intersystem individual, you probably won't see the inferred value though.如果您导航到系统间个体,您可能看不到推断值。 To show it, go to Reasoner > Configure… and check the Data Property Assertions option:要显示它,go 到 Reasoner > Configure… 并选中 Data Property Assertions 选项:

在此处输入图像描述

After that, you may need to restart the reasoner (Reasoner > None; Reasoner > Pellet; Reasoner > Start Reasoner), but afterward you'll be able to see the inferred values:之后,您可能需要重新启动推理器(Reasoner > None;Reasoner > Pellet;Reasoner > Start Reasoner),但之后您将能够看到推断值:

推断数据属性断言

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

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