Hi Dave,
I found the problem despite i don¹t understand why. I define the follow
two rules:
(?x exa:seaPartner ?y) <-
(?x exa:playSport ?s1),
(?y exa:playSport ?s2),
notEqual(?x, ?y),
(?s1 rdf:type exa:SeaSport),
(?s2 rdf:type exa:SeaSport).
(?x exa:seaPartner2 ?y) <-
(?x exa:playSport ?s1),
(?y exa:playSport ?s2),
notEqual(?x, ?y),
(?s1 rdf:type exa:SeaSport),
(?s2 rdf:type exa:SeaSport).
In my ontology, I have the follow definition:
<owl:ObjectProperty rdf:about="&exa;seaPartner">
<rdfs:label>seaPartner</rdfs:label>
<rdfs:domain rdf:resource="&exa;Person"/>
<rdfs:range rdf:resource="&exa;Person"/>
<rdf:type rdf:resource="&owl;FunctionalProperty" />
</owl:ObjectProperty>
exa:seaPartner2 returns the expected results while exa:seaPartner returns
the results that I already showed before.
Any reason for this behaviour?
Miguel
On 08/03/14 18:58, "Dave Reynolds" <[email protected]> wrote:
>On 08/03/14 13:05, Miguel Bento Alves wrote:
>> I have an ontology where is defined that several sports are played by
>> several people. if you want to consult it, the file is in the following
>> link:
>> https://www.dropbox.com/s/vcazac9vdvx4me6/schema_data_Sport2.xml
>>
>>
>> I have the follow jena rule:
>>
>> (?x exa:seaPartner ?y) <-
>> (?x exa:playSport ?s1),
>> (?y exa:playSport ?s2),
>> notEqual(?x, ?y),
>> (?s1 rdf:type exa:SeaSport),
>> (?s2 rdf:type exa:SeaSport).
>>
>> When I execute the follow SPARQL command:
>> prefix exa: <http://www.example.org/example#>
>> select ?x ?y
>> where {
>> ?x exa:sportPartner ?y .
>> }
>
>I assume you mean exa:seaPartner.
>
>> the output is:
>> x -> exa:Ricardo; y -> exa:Miguel;
>> x -> exa:Miguel; y -> exa:Ricardo;
>> x -> exa:Miguel; y -> null:null;
>> x -> exa:Ricardo; y -> null:null;
>>
>> I don't understand why the last two rows are listed.
>
>Works for me:
>
>"""
> String NS = "http://www.example.org/example#";
> PrintUtil.registerPrefix("eax", NS);
>
> Model data =
>FileManager.get().loadModel("data/schema_data_Sport2.rdf");
> List<Rule> rules = Rule.rulesFromURL("file:data/test.rules");
> GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
> InfModel inf = ModelFactory.createInfModel(reasoner, data);
> inf.setNsPrefixes(data);
> printStatements(inf, null, inf.createProperty(NS + "seaPartner"),
>null);
>
> String query = "prefix exa: <http://www.example.org/example#>
>select ?x ?y where { ?x exa:seaPartner ?y . }";
> QueryExecution qexec = QueryExecutionFactory.create(query, inf);
> ResultSetFormatter.out( qexec.execSelect() );
>"""
>
>where test.rules is your rule, produces:
>
> - (eax:Ricardo eax:seaPartner eax:Miguel)
> - (eax:Miguel eax:seaPartner eax:Ricardo)
>
>--------------------------------------------------------------------------
>-------------
>| x | y
> |
>==========================================================================
>=============
>| <http://www.example.org/example#Ricardo> |
><http://www.example.org/example#Miguel> |
>| <http://www.example.org/example#Miguel> |
><http://www.example.org/example#Ricardo> |
>--------------------------------------------------------------------------
>-------------
>
>Perhaps you have some other rules, such as the OWL rules?
>
>Dave
>