On 09/07/14 11:16, Zahir Kali wrote:
Hello,
i am working about inferences on Jena. I would test that a property is a
particular string. I have an ontology about servers, an individuals like this:
<owl:NamedIndividualrdf:about="&data;serveur-106216"><heberge rdf:resource="&data;applications-105049"/><rdf:type
rdf:resource="&data;serveur"/><identifiant-reseau rdf:datatype="&xsd;string">SRVLINMAGZ06</identifiant-reseau><status
rdf:datatype="&xsd;string">Enservice</status><svr-numero-serie rdf:datatype="&xsd;string">-</svr-numero-serie></owl:NamedIndividual>
i would add a new information (new property) to the servers that have a property
identifiant-reseau="POLO"
so, for this i have written a Jena rule like this:
[rule:(?S rdf:type data:serveur),(?S data:identifiant-reseau "POLO")->(?S
data:newproperty "TEST")]
But obviously, the test (?S data:identifiant-reseau "POLO") don't work.
Please, Have you an idea?
Not sure what you mean by "obviously".
That rule won't fire on that data because the value of
data:identifiant-reseau is "SRVLINMAGZ06" not "POLO".
But it will fire on matching data. So if I try a test model:
[[[
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix data: <http://www.openjena.org/tests#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
data:test rdf:type data:serveur;
data:identifiant-reseau "POLO"^^xsd:string.
]]]
with the rule file:
[[[
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix data: <http://www.openjena.org/tests#>
[rule:(?S rdf:type data:serveur),(?S data:identifiant-reseau
"POLO")->(?S data:newproperty "TEST")]
]]]
and the code:
[[[
Model data = FileManager.get().loadModel("data/temp.ttl");
List<Rule> rules = Rule.rulesFromURL("file:data/test.rules");
GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
InfModel inf = ModelFactory.createInfModel(reasoner, data);
inf.write(System.out, "Turtle");
]]]
then I see the output:
[[[
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix data: <http://www.openjena.org/tests#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
data:test a data:serveur ;
data:identifiant-reseau "POLO"^^xsd:string ;
data:newproperty "TEST" .
]]]
Dave