Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result of group by contains unexpected rows #56

Open
LorenzBuehmann opened this issue May 19, 2019 · 3 comments
Open

Result of group by contains unexpected rows #56

LorenzBuehmann opened this issue May 19, 2019 · 3 comments

Comments

@LorenzBuehmann
Copy link

LorenzBuehmann commented May 19, 2019

Hi,

I'm using latest Protege 5.5.0 and the installed SWRL Tab plugin version is 2.0.6

Let's assume the following data just consisting of 3 classes and 5 individuals.

@prefix : <http://www.semanticweb.org/me/ontologies/2019/4/untitled-ontology-543#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<http://www.semanticweb.org/me/ontologies/2019/4/untitled-ontology-543> rdf:type owl:Ontology .

:C1 rdf:type owl:Class .
:C2 rdf:type owl:Class .
:C3 rdf:type owl:Class .

:a rdf:type owl:NamedIndividual ,
            :C1 .
:b rdf:type owl:NamedIndividual ,
            :C1 , :C2 .
:c rdf:type owl:NamedIndividual ,
            :C1 , :C2 ,  :C3 .
:d rdf:type owl:NamedIndividual ,
            :C1 , :C2 , :C3 .
:e rdf:type owl:NamedIndividual ,
            :C2 .

The task of the SQWRL query is to compute the number of classes each individual belongs to.

The query I tried is

abox:caa(?cls, ?ind) . sqwrl:makeBag(?bag, ?cls) ^ sqwrl:groupBy(?bag, ?ind) . sqwrl:size(?n, ?bag) -> sqwrl:select(?ind, ?n)

it works mostly as expected except that it also returns some results that shouldn't occur:


+-------------+------------+
|     ind     |     n      |
+-------------+------------+
| autogen0:C1 | autogen0:a |
| autogen0:C1 | autogen0:b |
| autogen0:C1 | autogen0:c |
| autogen0:C1 | autogen0:d |
| autogen0:C2 | autogen0:b |
| autogen0:C2 | autogen0:c |
| autogen0:C2 | autogen0:d |
| autogen0:C2 | autogen0:e |
| autogen0:C3 | autogen0:c |
| autogen0:C3 | autogen0:d |
| autogen0:a  | 1          |
| autogen0:b  | 2          |
| autogen0:c  | 3          |
| autogen0:d  | 3          |
| autogen0:e  | 1          |
+-------------+------------+

So the last 5 rows are indeed what I'd expect, but I can't explain the other rows. Any ideas what I'm doing wrong?

I assume it has something to do with the "meta-axioms" like :C1 rdf:type owl:Class, am I right? Is there any chance to omit those entity declaration axioms? And also, the number n for those cases is clearly not a number so it looks like the size built-in fails somehow?

@martinjoconnor
Copy link
Member

This is very odd. I will take a look.

@martinjoconnor
Copy link
Member

Works fine for me. See enclosed file containing your classes and individuals and a SQWRL query.

SQWRLCAAReport.owl.txt

@LorenzBuehmann
Copy link
Author

Strange. Looks like I'm misusing the plugin somehow. Maybe it happened because I changed a rule after getting some result from a previous run. Is the state of the table somewhere not refreshed?

I have some steps to reproduce an issue:

  1. load the ontology open the SQWRL tab, select the rule S1 and "run" it -> result as expected
  2. edit the rule to abox:caa(?cls, ?ind) -> sqwrl:select(?cls, ?i) ^ sqwrl:orderby(?i), select S1 and "rerun" it
  3. revert the changes, i.e. edit the rule to abox:caa(?cls, ?ind) . sqwrl:makeBag(?bag, ?cls) ^ sqwrl:groupBy(?bag, ?ind) . sqwrl:size(?n, ?bag) -> sqwrl:select(?ind, ?n), select S1 and "rerun" it

This time I'm getting again what I got last time (screenshot to prove I'm not crazy):
sqrwltab

So basically, what you can see here is that result from previous run is still in the table.

While further changed the rule back and forth I got also into a state where neither "run" nor "rerun" (from S1 Tab) do change anything - I guess at this point the plugin crashed completely:

See the S1 tab to review results of the SQWRL query.
The query took 870 milliseconds. 5 rows were returned.
Exception running SQWRL query 'S1': error running SQWRL queries: Internal error comparing rows
Exception running SQWRL query S1: error running SQWRL queries: Internal error comparing rows: Internal error comparing rows: attempt to compare a org.swrlapi.factory.DefaultSQWRLLiteralResultValue with a org.swrlapi.factory.DefaultSQWRLClassResultValue 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants