Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

rdf - SWRL rules don't infer new Object and Data Property Assertions

I have created this ontology which contains two classes: Blood-Sugar and Services. Blood-Sugar has two data properties: hasValu with range xsd:int, and hasStatut with range xsd:string. The object property triggerService has Blood-Sugar as domain and Service as range.

I want to infer a data property assertion with this rule:

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

Then I want to infer a new object property with this rule:

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

However, the reasoner does not give me the result that I want when I create individuals to which the rules should apply. Here is an ontology that demonstrates this behavior:

<?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:

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

But the reasonner does not give me the result that i want when I creat instances !!!

A bit more detail would be helpful here. How do you know that the reasoner (and which reasoner are you using, by the way?) isn't inferring the desired properties? Did you enable the reasoner? Did you run a query to check whether the inferences were present? Did you set the configuration in Protégé to show all the appropriate inferences?

At any rate, thank you for providing an ontology to reproduce your results. I was able to load it into Protégé, run the Pellet reasoner, and I can get the following inferences:

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

blood sugar results

While Pellet is able to compute all of these inferences, Protégé only shows inferences for object properties by default; you have to go into the Reasoner > Configure… menu and makes sure that under the "Displayed Individual Inferences" section the "Data Property Assertions" option is checked. Turning on the Pellet reasoner and setting this option is described in more detail in my answer to Ontology property definition in Protégé-OWL / SWRL.

reasoner configuration option


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...