I'm on holiday and have weak internet connection so it's hard to look at
the details.
To repeat my earlier question I assume you must be enabling some version
of the OWL results somewhere, perhaps by an @include? Without more
information on your set up it's hard to reproduce it.
My guess it that you are using the full OWL rules or maybe OWLMini, in
which try with OWLMicro instead.
The full OWL rules go round creating bNodes for things that they know
exist but don't know the identify of. Which means that the resulting
graph can be unlean. The bNodes in your case aren't wrong, each of those
people do have a seaPartner, but I understand that you would prefer a
lean graph.
I'm a little surprised that the owl:FunctionalProperty rules would do
that, but if that's the only mention of exa:seaSport in your ontology I
guess they must. Suggests there might be an underlying problem but so
far there is no incorrect answer there, just a less than helpful one :)
Dave
On 09/03/14 23:32, Miguel Bento Alves wrote:
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