Usage of infered property values in SWRL

7 messages Options
Embed this post
Permalink
Michael Lodemann

Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
Hello,

is there a way to transform infered property values (of transitive
properties) to asserted knowledge via the protege 3.4.1 gui?
Or how is it possible to use infered property values in SWRL rules? It
seems to me infered knowledge by transitive properties is not recognized
and used in S(Q)WRL. Is this true?

Hoping for help,
Michael
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Michael Lodemann

Re: Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
I was able to solve this by myself using following code

SWRLRuleEngineBridge bridge =
BridgeFactory.createBridge("SWRLJessBridge", owlModel);
bridge.infer();              
               
String filePath =
owlModel.getOWLFilePath().substring(owlModel.getOWLFilePath().indexOf("file:/")+6);
Collection errors = new ArrayList();
owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);
System.out.println("File saved with " + errors.size() + " errors.");
               
I'm a bit confused because before I only used SQWRLQueryEngine in order
to run all queries and the subsequent rules but it hasn't the abilty of
persisting the inferences, has it?

Regards,
Michael


Michael Lodemann schrieb:

> Hello,
>
> is there a way to transform infered property values (of transitive
> properties) to asserted knowledge via the protege 3.4.1 gui?
> Or how is it possible to use infered property values in SWRL rules? It
> seems to me infered knowledge by transitive properties is not recognized
> and used in S(Q)WRL. Is this true?
>
> Hoping for help,
> Michael
> _______________

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Michael Lodemann

Re: Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
Too early.

Saving inferred knowledge obtained from SWRL rules works that way ...
but inferred property knowledge e.g. from transitive properties doesn't
appear to be saved with the code lines below. I also have following
reasoner code before these lines:

ReasonerManager reasonerManager = ReasonerManager.getInstance();
ProtegeReasoner reasoner =
reasonerManager.createProtegeReasoner(owlModel,
ProtegePelletOWLAPIReasoner.class);
reasoner.initialize();
reasoner.computeInferredHierarchy();
reasoner.computeInferredIndividualTypes();
reasoner.classifyTaxonomy();
           
So, is there a way to persist inferred property knowledge in the model?

Cheers,
Michael


Michael Lodemann schrieb:

> I was able to solve this by myself using following code
>
> SWRLRuleEngineBridge bridge =
> BridgeFactory.createBridge("SWRLJessBridge", owlModel);
> bridge.infer();              
>                
> String filePath =
> owlModel.getOWLFilePath().substring(owlModel.getOWLFilePath().indexOf("file:/")+6);
> Collection errors = new ArrayList();
> owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);
> System.out.println("File saved with " + errors.size() + " errors.");
>                
> I'm a bit confused because before I only used SQWRLQueryEngine in order
> to run all queries and the subsequent rules but it hasn't the abilty of
> persisting the inferences, has it?
>
> Regards,
> Michael
>
>
> Michael Lodemann schrieb:
>  
>> Hello,
>>
>> is there a way to transform infered property values (of transitive
>> properties) to asserted knowledge via the protege 3.4.1 gui?
>> Or how is it possible to use infered property values in SWRL rules? It
>> seems to me infered knowledge by transitive properties is not recognized
>> and used in S(Q)WRL. Is this true?
>>
>> Hoping for help,
>> Michael
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Michael Lodemann

Re: Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
I'm a kind of desperate.
It tried the complex way of saving inferred properties in the model for
reuse ... doesn't seem to work.

And the simple and obvious way doensn't work as well. Minimal example:

- Three Persons - Adam, Berta, Cesar are related via transitive property
"hasAncestor" - Adam with Berta and Berta with Cesar
- Adam and Cesar are blond via Datatype property "hasBlondHair"
- this rule should be able to determine whether there are blond ancestors:
Person(?p1) ? Person(?p2) ? hasAncestor(?p1, ?p2) ? hasBlondHair(?p1,
true) ? hasBlondHair(?p2, true) ? BlondAncestor(?p1) ? BlondAncestor(?p2)

... but only if the inferred relation between Adam and Cesar is detected.

But unfortunately it isn't.

Can anyone confirm this?


Turtle code:

default:Person
rdf:type owl:Class .

default:BlondAncestor
rdf:type owl:Class .

default:hasAncestor
rdf:type owl:TransitiveProperty , owl:ObjectProperty ;
rdfs:domain default:Person ;
rdfs:range default:Person .

default:hasBlondHair
rdf:type owl:DatatypeProperty ;
rdfs:domain default:Person ;
rdfs:range xsd:boolean .

default:Adam
rdf:type default:Person ;
default:hasAncestor default:Berta ;
default:hasBlondHair
"true"^^xsd:boolean .

default:Berta
rdf:type default:Person ;
default:hasAncestor default:Cesar ;
default:hasBlondHair
"false"^^xsd:boolean .

default:Cesar
rdf:type default:Person ;
default:hasBlondHair
"true"^^xsd:boolean .




Michael Lodemann schrieb:

> Too early.
>
> Saving inferred knowledge obtained from SWRL rules works that way ...
> but inferred property knowledge e.g. from transitive properties doesn't
> appear to be saved with the code lines below. I also have following
> reasoner code before these lines:
>
> ReasonerManager reasonerManager = ReasonerManager.getInstance();
> ProtegeReasoner reasoner =
> reasonerManager.createProtegeReasoner(owlModel,
> ProtegePelletOWLAPIReasoner.class);
> reasoner.initialize();
> reasoner.computeInferredHierarchy();
> reasoner.computeInferredIndividualTypes();
> reasoner.classifyTaxonomy();
>            
> So, is there a way to persist inferred property knowledge in the model?
>
> Cheers,
> Michael
>
>
> Michael Lodemann schrieb:
>  
>> I was able to solve this by myself using following code
>>
>> SWRLRuleEngineBridge bridge =
>> BridgeFactory.createBridge("SWRLJessBridge", owlModel);
>> bridge.infer();              
>>                
>> String filePath =
>> owlModel.getOWLFilePath().substring(owlModel.getOWLFilePath().indexOf("file:/")+6);
>> Collection errors = new ArrayList();
>> owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);
>> System.out.println("File saved with " + errors.size() + " errors.");
>>                
>> I'm a bit confused because before I only used SQWRLQueryEngine in order
>> to run all queries and the subsequent rules but it hasn't the abilty of
>> persisting the inferences, has it?
>>
>> Regards,
>> Michael
>>
>>
>> Michael Lodemann schrieb:
>>  
>>    
>>> Hello,
>>>
>>> is there a way to transform infered property values (of transitive
>>> properties) to asserted knowledge via the protege 3.4.1 gui?
>>> Or how is it possible to use infered property values in SWRL rules? It
>>> seems to me infered knowledge by transitive properties is not recognized
>>> and used in S(Q)WRL. Is this true?
>>>
>>> Hoping for help,
>>> Michael
_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Martin O'Connor

Re: Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
While the Jess implementation for SWRL does not automatically infer
transitive property relationships, you can write rules yourself on a
property by property basis to infer them.

Martin

Michael Lodemann wrote:

> I'm a kind of desperate.
> It tried the complex way of saving inferred properties in the model for
> reuse ... doesn't seem to work.
>
> And the simple and obvious way doensn't work as well. Minimal example:
>
> - Three Persons - Adam, Berta, Cesar are related via transitive property
> "hasAncestor" - Adam with Berta and Berta with Cesar
> - Adam and Cesar are blond via Datatype property "hasBlondHair"
> - this rule should be able to determine whether there are blond ancestors:
> Person(?p1) ? Person(?p2) ? hasAncestor(?p1, ?p2) ? hasBlondHair(?p1,
> true) ? hasBlondHair(?p2, true) ? BlondAncestor(?p1) ? BlondAncestor(?p2)
>
> ... but only if the inferred relation between Adam and Cesar is detected.
>
> But unfortunately it isn't.
>
> Can anyone confirm this?
>
>
> Turtle code:
>
> default:Person
> rdf:type owl:Class .
>
> default:BlondAncestor
> rdf:type owl:Class .
>
> default:hasAncestor
> rdf:type owl:TransitiveProperty , owl:ObjectProperty ;
> rdfs:domain default:Person ;
> rdfs:range default:Person .
>
> default:hasBlondHair
> rdf:type owl:DatatypeProperty ;
> rdfs:domain default:Person ;
> rdfs:range xsd:boolean .
>
> default:Adam
> rdf:type default:Person ;
> default:hasAncestor default:Berta ;
> default:hasBlondHair
> "true"^^xsd:boolean .
>
> default:Berta
> rdf:type default:Person ;
> default:hasAncestor default:Cesar ;
> default:hasBlondHair
> "false"^^xsd:boolean .
>
> default:Cesar
> rdf:type default:Person ;
> default:hasBlondHair
> "true"^^xsd:boolean .
>
>
>
>
> Michael Lodemann schrieb:
>  
>> Too early.
>>
>> Saving inferred knowledge obtained from SWRL rules works that way ...
>> but inferred property knowledge e.g. from transitive properties doesn't
>> appear to be saved with the code lines below. I also have following
>> reasoner code before these lines:
>>
>> ReasonerManager reasonerManager = ReasonerManager.getInstance();
>> ProtegeReasoner reasoner =
>> reasonerManager.createProtegeReasoner(owlModel,
>> ProtegePelletOWLAPIReasoner.class);
>> reasoner.initialize();
>> reasoner.computeInferredHierarchy();
>> reasoner.computeInferredIndividualTypes();
>> reasoner.classifyTaxonomy();
>>            
>> So, is there a way to persist inferred property knowledge in the model?
>>
>> Cheers,
>> Michael
>>
>>
>> Michael Lodemann schrieb:
>>  
>>    
>>> I was able to solve this by myself using following code
>>>
>>> SWRLRuleEngineBridge bridge =
>>> BridgeFactory.createBridge("SWRLJessBridge", owlModel);
>>> bridge.infer();              
>>>                
>>> String filePath =
>>> owlModel.getOWLFilePath().substring(owlModel.getOWLFilePath().indexOf("file:/")+6);
>>> Collection errors = new ArrayList();
>>> owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);
>>> System.out.println("File saved with " + errors.size() + " errors.");
>>>                
>>> I'm a bit confused because before I only used SQWRLQueryEngine in order
>>> to run all queries and the subsequent rules but it hasn't the abilty of
>>> persisting the inferences, has it?
>>>
>>> Regards,
>>> Michael
>>>
>>>
>>> Michael Lodemann schrieb:
>>>  
>>>    
>>>      
>>>> Hello,
>>>>
>>>> is there a way to transform infered property values (of transitive
>>>> properties) to asserted knowledge via the protege 3.4.1 gui?
>>>> Or how is it possible to use infered property values in SWRL rules? It
>>>> seems to me infered knowledge by transitive properties is not recognized
>>>> and used in S(Q)WRL. Is this true?
>>>>
>>>> Hoping for help,
>>>> Michael
>>>>        
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>
>  

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Martin O'Connor

Re: Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
In reply to this post by Michael Lodemann
The query engine does not persist anything. You need to use the rule engine.

Martin

Michael Lodemann wrote:

> I was able to solve this by myself using following code
>
> SWRLRuleEngineBridge bridge =
> BridgeFactory.createBridge("SWRLJessBridge", owlModel);
> bridge.infer();              
>                
> String filePath =
> owlModel.getOWLFilePath().substring(owlModel.getOWLFilePath().indexOf("file:/")+6);
> Collection errors = new ArrayList();
> owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);
> System.out.println("File saved with " + errors.size() + " errors.");
>                
> I'm a bit confused because before I only used SQWRLQueryEngine in order
> to run all queries and the subsequent rules but it hasn't the abilty of
> persisting the inferences, has it?
>
> Regards,
> Michael
>
>
> Michael Lodemann schrieb:
>  
>> Hello,
>>
>> is there a way to transform infered property values (of transitive
>> properties) to asserted knowledge via the protege 3.4.1 gui?
>> Or how is it possible to use infered property values in SWRL rules? It
>> seems to me infered knowledge by transitive properties is not recognized
>> and used in S(Q)WRL. Is this true?
>>
>> Hoping for help,
>> Michael
>> _______________
>>    
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
>
>  

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03 
Michael Lodemann

Re: Usage of infered property values in SWRL

Reply Threaded More More options
Print post
Permalink
In reply to this post by Martin O'Connor
Thanks Martin,

but I'm not able to follow your explanation. What do you mean by "rules
on a property by property basis"? Can you give an illustration using the
example below?

I had a clue of Jess not being able to infer transitive property
relationship, so I have following strategy:

1. Invoke the Pellet reasoner in order to infer transitive property
relationship
2. Persist these inferences in the model
3. Apply the SWRL rules in order to perform the "high level" inferences
with the whole knowledge about the transitive interconnections.
 
But I'm stuck somewhere between 1 and 2. I need some piece of code
showing me how to obtain infered transitive property values and store
them in my model.
Perhaps I can use the ProtegeReasoner interface? Unfortunately I didn't
find a method which fits. Do you have a hint for me?

Thanks in advance,
Michael



And using

> SWRLRuleEngineBridge bridge =
> BridgeFactory.createBridge("SWRLJessBridge", owlModel);
> bridge.infer();
> owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);


 
Martin O'Connor schrieb:

> While the Jess implementation for SWRL does not automatically infer
> transitive property relationships, you can write rules yourself on a
> property by property basis to infer them.
>
> Martin
>
> Michael Lodemann wrote:
>  
>> I'm a kind of desperate.
>> It tried the complex way of saving inferred properties in the model for
>> reuse ... doesn't seem to work.
>>
>> And the simple and obvious way doensn't work as well. Minimal example:
>>
>> - Three Persons - Adam, Berta, Cesar are related via transitive property
>> "hasAncestor" - Adam with Berta and Berta with Cesar
>> - Adam and Cesar are blond via Datatype property "hasBlondHair"
>> - this rule should be able to determine whether there are blond ancestors:
>> Person(?p1) ? Person(?p2) ? hasAncestor(?p1, ?p2) ? hasBlondHair(?p1,
>> true) ? hasBlondHair(?p2, true) ? BlondAncestor(?p1) ? BlondAncestor(?p2)
>>
>> ... but only if the inferred relation between Adam and Cesar is detected.
>>
>> But unfortunately it isn't.
>>
>> Can anyone confirm this?
>>
>>
>> Turtle code:
>>
>> default:Person
>> rdf:type owl:Class .
>>
>> default:BlondAncestor
>> rdf:type owl:Class .
>>
>> default:hasAncestor
>> rdf:type owl:TransitiveProperty , owl:ObjectProperty ;
>> rdfs:domain default:Person ;
>> rdfs:range default:Person .
>>
>> default:hasBlondHair
>> rdf:type owl:DatatypeProperty ;
>> rdfs:domain default:Person ;
>> rdfs:range xsd:boolean .
>>
>> default:Adam
>> rdf:type default:Person ;
>> default:hasAncestor default:Berta ;
>> default:hasBlondHair
>> "true"^^xsd:boolean .
>>
>> default:Berta
>> rdf:type default:Person ;
>> default:hasAncestor default:Cesar ;
>> default:hasBlondHair
>> "false"^^xsd:boolean .
>>
>> default:Cesar
>> rdf:type default:Person ;
>> default:hasBlondHair
>> "true"^^xsd:boolean .
>>
>>
>>
>>
>> Michael Lodemann schrieb:
>>  
>>    
>>> Too early.
>>>
>>> Saving inferred knowledge obtained from SWRL rules works that way ...
>>> but inferred property knowledge e.g. from transitive properties doesn't
>>> appear to be saved with the code lines below. I also have following
>>> reasoner code before these lines:
>>>
>>> ReasonerManager reasonerManager = ReasonerManager.getInstance();
>>> ProtegeReasoner reasoner =
>>> reasonerManager.createProtegeReasoner(owlModel,
>>> ProtegePelletOWLAPIReasoner.class);
>>> reasoner.initialize();
>>> reasoner.computeInferredHierarchy();
>>> reasoner.computeInferredIndividualTypes();
>>> reasoner.classifyTaxonomy();
>>>            
>>> So, is there a way to persist inferred property knowledge in the model?
>>>
>>> Cheers,
>>> Michael
>>>
>>>
>>> Michael Lodemann schrieb:
>>>  
>>>    
>>>      
>>>> I was able to solve this by myself using following code
>>>>
>>>> SWRLRuleEngineBridge bridge =
>>>> BridgeFactory.createBridge("SWRLJessBridge", owlModel);
>>>> bridge.infer();              
>>>>                
>>>> String filePath =
>>>> owlModel.getOWLFilePath().substring(owlModel.getOWLFilePath().indexOf("file:/")+6);
>>>> Collection errors = new ArrayList();
>>>> owlModel.save(new File(filePath).toURI(), FileUtils.langXMLAbbrev, errors);
>>>> System.out.println("File saved with " + errors.size() + " errors.");
>>>>                
>>>> I'm a bit confused because before I only used SQWRLQueryEngine in order
>>>> to run all queries and the subsequent rules but it hasn't the abilty of
>>>> persisting the inferences, has it?
>>>>
>>>> Regards,
>>>> Michael
>>>>
>>>>
>>>> Michael Lodemann schrieb:
>>>>  
>>>>    
>>>>      
>>>>        
>>>>> Hello,
>>>>>
>>>>> is there a way to transform infered property values (of transitive
>>>>> properties) to asserted knowledge via the protege 3.4.1 gui?
>>>>> Or how is it possible to use infered property values in SWRL rules? It
>>>>> seems to me infered knowledge by transitive properties is not recognized
>>>>> and used in S(Q)WRL. Is this true?
>>>>>
>>>>> Hoping for help,
>>>>> Michael
>>>>>        

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03