1

我创建了这个包含两个类的本体:Blood-SugarServicesBlood-Sugar有两个数据属性:范围为 xsd:int 的hasValu和范围为 xsd:string 的hasStatut。对象属性triggerServiceBlood-Sugar作为域,将Service作为范围。

我想用这个规则推断一个数据属性断言:

Blood_Sugar(?x) ∧ hasValue(?x, ?y) ∧ swrlb:greaterThan(?y, 126) ∧ swrlb:lessThan(?y, 500) → hasStatut(?x, "High")

然后我想用这个规则推断一个新的对象属性:

Blood_Sugar(?x) ∧ hasStatut(?x, "High") ∧ Service(?s) → triggerService(?x, ?s)

但是,当我创建规则应适用的个体时,推理器并没有给我想要的结果。这是一个演示此行为的本体:

<?xml version="1.0"?>


<!DOCTYPE rdf:RDF [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY swrl "http://www.w3.org/2003/11/swrl#" >
    <!ENTITY swrlb "http://www.w3.org/2003/11/swrlb#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
    <!ENTITY protege "http://protege.stanford.edu/plugins/owl/protege#" >
    <!ENTITY xsp "http://www.owl-ontologies.com/2005/08/07/xsp.owl#" >
    <!ENTITY swrla "http://swrl.stanford.edu/ontologies/3.3/swrla.owl#" >
    <!ENTITY sqwrl "http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl#" >
]>


<rdf:RDF xmlns="http://www.owl-ontologies.com/Ontology1391620136.owl#"
     xml:base="http://www.owl-ontologies.com/Ontology1391620136.owl"
     xmlns:swrla="http://swrl.stanford.edu/ontologies/3.3/swrla.owl#"
     xmlns:sqwrl="http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#"
     xmlns:swrl="http://www.w3.org/2003/11/swrl#"
     xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#"
     xmlns:swrlb="http://www.w3.org/2003/11/swrlb#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#">
    <owl:Ontology rdf:about="">
        <owl:imports rdf:resource="http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl"/>
        <owl:imports rdf:resource="http://swrl.stanford.edu/ontologies/3.3/swrla.owl"/>
    </owl:Ontology>
    <swrl:Variable rdf:ID="s"/>
    <swrl:Variable rdf:ID="x"/>
    <swrl:Variable rdf:ID="y"/>
    <owl:Class rdf:ID="Blood_Sugar"/>
    <swrl:Imp rdf:ID="Rule-2">
        <swrl:body>
            <swrl:AtomList>
                <rdf:first>
                    <rdf:Description>
                        <rdf:type rdf:resource="&swrl;ClassAtom"/>
                        <swrl:argument1>
                            <rdf:Description rdf:about="#x"/>
                        </swrl:argument1>
                        <swrl:classPredicate rdf:resource="#Blood_Sugar"/>
                    </rdf:Description>
                </rdf:first>
                <rdf:rest>
                    <swrl:AtomList>
                        <rdf:first>
                            <rdf:Description>
                                <rdf:type rdf:resource="&swrl;DatavaluedPropertyAtom"/>
                                <swrl:argument2 rdf:datatype="&xsd;string">High</swrl:argument2>
                                <swrl:argument1>
                                    <rdf:Description rdf:about="#x"/>
                                </swrl:argument1>
                                <swrl:propertyPredicate rdf:resource="#hasStatut"/>
                            </rdf:Description>
                        </rdf:first>
                        <rdf:rest>
                            <swrl:AtomList>
                                <rdf:first>
                                    <rdf:Description>
                                        <rdf:type rdf:resource="&swrl;ClassAtom"/>
                                        <swrl:argument1>
                                            <rdf:Description rdf:about="#s"/>
                                        </swrl:argument1>
                                        <swrl:classPredicate rdf:resource="#Service"/>
                                    </rdf:Description>
                                </rdf:first>
                                <rdf:rest rdf:resource="&rdf;nil"/>
                            </swrl:AtomList>
                        </rdf:rest>
                    </swrl:AtomList>
                </rdf:rest>
            </swrl:AtomList>
        </swrl:body>
        <swrl:head>
            <swrl:AtomList>
                <rdf:first>
                    <rdf:Description>
                        <rdf:type rdf:resource="&swrl;IndividualPropertyAtom"/>
                        <swrl:argument2>
                            <rdf:Description rdf:about="#s"/>
                        </swrl:argument2>
                        <swrl:argument1>
                            <rdf:Description rdf:about="#x"/>
                        </swrl:argument1>
                        <swrl:propertyPredicate rdf:resource="#triggerService"/>
                    </rdf:Description>
                </rdf:first>
                <rdf:rest rdf:resource="&rdf;nil"/>
            </swrl:AtomList>
        </swrl:head>
    </swrl:Imp>
    <swrl:Imp rdf:ID="Rule-1">
        <swrl:body>
            <swrl:AtomList>
                <rdf:first>
                    <rdf:Description>
                        <rdf:type rdf:resource="&swrl;ClassAtom"/>
                        <swrl:argument1>
                            <rdf:Description rdf:about="#x"/>
                        </swrl:argument1>
                        <swrl:classPredicate rdf:resource="#Blood_Sugar"/>
                    </rdf:Description>
                </rdf:first>
                <rdf:rest>
                    <swrl:AtomList>
                        <rdf:first>
                            <rdf:Description>
                                <rdf:type rdf:resource="&swrl;DatavaluedPropertyAtom"/>
                                <swrl:argument2>
                                    <rdf:Description rdf:about="#y"/>
                                </swrl:argument2>
                                <swrl:argument1>
                                    <rdf:Description rdf:about="#x"/>
                                </swrl:argument1>
                                <swrl:propertyPredicate rdf:resource="#hasValue"/>
                            </rdf:Description>
                        </rdf:first>
                        <rdf:rest>
                            <swrl:AtomList>
                                <rdf:first>
                                    <rdf:Description>
                                        <rdf:type rdf:resource="&swrl;BuiltinAtom"/>
                                        <swrl:arguments>
                                            <rdf:List>
                                                <rdf:first>
                                                    <rdf:Description rdf:about="#y"/>
                                                </rdf:first>
                                                <rdf:rest>
                                                    <rdf:List>
                                                        <rdf:first rdf:datatype="&xsd;long">126</rdf:first>
                                                        <rdf:rest rdf:resource="&rdf;nil"/>
                                                    </rdf:List>
                                                </rdf:rest>
                                            </rdf:List>
                                        </swrl:arguments>
                                        <swrl:builtin>
                                            <rdf:Description rdf:about="&swrlb;greaterThan"/>
                                        </swrl:builtin>
                                    </rdf:Description>
                                </rdf:first>
                                <rdf:rest>
                                    <swrl:AtomList>
                                        <rdf:first>
                                            <rdf:Description>
                                                <rdf:type rdf:resource="&swrl;BuiltinAtom"/>
                                                <swrl:arguments>
                                                    <rdf:List>
                                                        <rdf:first>
                                                            <rdf:Description rdf:about="#y"/>
                                                        </rdf:first>
                                                        <rdf:rest>
                                                            <rdf:List>
                                                                <rdf:first rdf:datatype="&xsd;long">500</rdf:first>
                                                                <rdf:rest rdf:resource="&rdf;nil"/>
                                                            </rdf:List>
                                                        </rdf:rest>
                                                    </rdf:List>
                                                </swrl:arguments>
                                                <swrl:builtin>
                                                    <rdf:Description rdf:about="&swrlb;lessThan"/>
                                                </swrl:builtin>
                                            </rdf:Description>
                                        </rdf:first>
                                        <rdf:rest rdf:resource="&rdf;nil"/>
                                    </swrl:AtomList>
                                </rdf:rest>
                            </swrl:AtomList>
                        </rdf:rest>
                    </swrl:AtomList>
                </rdf:rest>
            </swrl:AtomList>
        </swrl:body>
        <swrl:head>
            <swrl:AtomList>
                <rdf:first>
                    <rdf:Description>
                        <rdf:type rdf:resource="&swrl;DatavaluedPropertyAtom"/>
                        <swrl:argument2 rdf:datatype="&xsd;string">High</swrl:argument2>
                        <swrl:argument1>
                            <rdf:Description rdf:about="#x"/>
                        </swrl:argument1>
                        <swrl:propertyPredicate rdf:resource="#hasStatut"/>
                    </rdf:Description>
                </rdf:first>
                <rdf:rest rdf:resource="&rdf;nil"/>
            </swrl:AtomList>
        </swrl:head>
    </swrl:Imp>
    <Blood_Sugar rdf:ID="Blood_Sugar_1">
        <hasValue rdf:datatype="&xsd;int">150</hasValue>
    </Blood_Sugar>
    <owl:DatatypeProperty rdf:ID="hasStatut">
        <rdfs:domain rdf:resource="#Blood_Sugar"/>
        <rdfs:range rdf:resource="&xsd;string"/>
    </owl:DatatypeProperty>
    <owl:DatatypeProperty rdf:ID="hasValue">
        <rdfs:domain rdf:resource="#Blood_Sugar"/>
        <rdfs:range rdf:resource="&xsd;int"/>
    </owl:DatatypeProperty>
    <owl:Class rdf:ID="Service"/>
    <Service rdf:ID="Service_1"/>
    <owl:ObjectProperty rdf:ID="triggerService">
        <rdfs:domain rdf:resource="#Blood_Sugar"/>
        <rdfs:range rdf:resource="#Service"/>
    </owl:ObjectProperty>
</rdf:RDF>
4

2 回答 2

4

但是当我创建实例时,reasonner 并没有给我想要的结果!

更多细节在这里会有所帮助。您怎么知道推理器(顺便说一下,您使用的是哪个推理器?)没有推断出所需的属性?你启用了推理器吗?您是否运行查询以检查推理是否存在?您是否在 Protégé 中设置了配置以显示所有适当的推论?

无论如何,感谢您提供本体来重现您的结果。我能够将它加载到 Protégé 中,运行 Pellet 推理器,我可以得到以下推论:

Blood_Sugar_1 triggerService Service_1
Blood_Sugar_1 hasStatut "High"^^string
Blood_Sugar_1 hasStatut "150"^^int

血糖结果

虽然 Pellet 能够计算所有这些推论,但 Protégé 默认只显示对象属性的推论;您必须进入 Reasoner > Configure... 菜单并确保在“Displayed Individual Inferences”部分下选中“Data Property Assertions”选项。我对Protégé-OWL / SWRL 中的本体属性定义的回答中更详细地描述了打开 Pellet 推理器并设置此选项。

推理机配置选项

于 2014-02-06T02:40:50.210 回答
0

根据您的评论,也许使用 SWRL 规则来推断新对象属性断言的示例将使您步入正轨。一些 OWL 2 推理器支持 SWRL 规则,所以我使用 Protégé 4.x 和 Pellet。SWRL 规则用于推断新的对象属性断言。例如,在以下本体中,有一个Person类,其中包含AliceBillCarlRaymond个人、一个对象属性likes和一个规则:

人(?x) → 喜欢(?x,Raymond)

启用 Pellet 推理器(Reasoner > Pellet,然后 Reasoner > Start Reasoner)后,我们得到了预期的结果。例如,比尔喜欢雷蒙德:

比尔喜欢雷蒙德

这是本体:

@prefix :      <http://example.org/swrl-example#> .
@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#> .

<http://example.org/swrl-example>
        a       owl:Ontology .

:Person  a      owl:Class .

:Raymond  a     owl:NamedIndividual , :Person .

:Alice  a       owl:NamedIndividual , :Person .

[ a          swrl:Imp ;
  swrl:body  [ a          swrl:AtomList ;
               rdf:first  [ a                    swrl:ClassAtom ;
                            swrl:argument1       <urn:swrl#x> ;
                            swrl:classPredicate  :Person
                          ] ;
               rdf:rest   ()

             ] ;
  swrl:head  [ a          swrl:AtomList ;
               rdf:first  [ a                       swrl:IndividualPropertyAtom ;
                            swrl:argument1          <urn:swrl#x> ;
                            swrl:argument2          :Raymond ;
                            swrl:propertyPredicate  :likes
                          ] ;
               rdf:rest   ()

             ]
] .

:Bill   a       owl:NamedIndividual , :Person .

:likes  a       owl:ObjectProperty .

:Carl   a       owl:NamedIndividual , :Person .

<urn:swrl#x>  a  swrl:Variable .
于 2014-02-04T15:57:20.140 回答