SQWRL Issue

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SQWRL Issue

Michael DeBellis-2
This relates to an issue I discussed a few days ago. Let me know if I should just file this as an issue on Github. It wasn't obvious to me where to file it and also I thought it worth reporting to the list because I've never used the makeSet operator in SQWRL so possibly I'm doing something wrong that someone can spot quickly. I'm using  Protégé Version 5.5.0 and Windows 10 Home version 1809. 

I can send the ontology (this is slightly different than the ontology I sent to Csongor today for a SPARQL issue) that replicates this but would prefer to send it directly to one individual rather than to the whole list. 

I have an ontology that uses a SWRL rule (developed via Machine learning) that detects possible FakeAccounts based on a set of parameters about the account and over a thousand data sets from Twitter. 

One of the things I want to show is the extra value that can be achieved by having the information modeled in an ontology. One example would be to find Accounts that are owned by users who also own FakeAccounts but those other Accounts don't meet the standards for a FakeAccount. Since the user owns one FakeAccount it might be desirable to know all the accounts they own. 

The DL: 

Account and isAccountFor some (Agent and hasAccount some FakeAccount)

will find these accounts but it will of course also find the actual Fake Accounts. So the question is how to separate this set from the set of FakeAccounts. Due to OWA we can't do it using DL. Dave was nice enough to give me the SPARQL query that would work but I'm having trouble using the SPARQL Tab with this ontology (that was the issue I sent the ontology to Csongor for). 

So I thought of an alternative using SQWRL. I created a defined class called SuspectAccount which is defined with the DL above (and works as expected). Then I created the following SQWRL query:

FakeAccount(?fa) ^ sqwrl:makeSet(?fas, ?fa) ^ SuspectAccount(?sa) ^ sqwrl:makeSet(?sas, ?sa) ^ sqwrl:difference(?pfa, ?fas, ?sas) -> sqwrl:select(?pfa)

What I thought this would do is to give me a new set ?pfa (possible fake accounts) that was the set difference between the FakeAccount set and the SuspectAccount set, i.e., those Accounts that are not FakeAccounts but are owned by a user who also owns at least one Fake Account. 

However, when I write this rule I get the "OK" button to highlight, indicating that it's syntactically correct and I click on it to add the rule. However, then I see that it looks different in the SQWRL tab than what I wrote. Some of the "^" signs has been replaced by a "."  The rule ends up looking like this:

FakeAccount(?fa)  .  sqwrl:makeSet(?fas, ?fa) ^ SuspectAccount(?sa) ^ sqwrl:makeSet(?sas, ?sa)  .  sqwrl:difference(?pfa, ?fas, ?sas) -> sqwrl:select(?pfa)

I try editing the rule again and changing the dots to ^ but the same thing happens, some of the  ^  get replaced by dots. BTW, the rule actually has the name of the ontology as a preface to all the non-SQWRL expressions but I see that often and it doesn't seem to effect how things work. 

I tried running the query just to see what happens. I'm able to run the Reasoner after adding this (what I think is malformed) rule but when I hit the "Run" button on the SQWRL tab Protege just hangs, it won't respond at all even to a close and I have to use cntl-alt-del to kill the process. 

Michael






_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: SQWRL Issue

Martin O'Connor-2


On Jul 12, 2019, at 11:44 AM, Michael DeBellis <[hidden email]> wrote:

So I thought of an alternative using SQWRL. I created a defined class called SuspectAccount which is defined with the DL above (and works as expected). Then I created the following SQWRL query:

FakeAccount(?fa) ^ sqwrl:makeSet(?fas, ?fa) ^ SuspectAccount(?sa) ^ sqwrl:makeSet(?sas, ?sa) ^ sqwrl:difference(?pfa, ?fas, ?sas) -> sqwrl:select(?pfa)

What I thought this would do is to give me a new set ?pfa (possible fake accounts) that was the set difference between the FakeAccount set and the SuspectAccount set, i.e., those Accounts that are not FakeAccounts but are owned by a user who also owns at least one Fake Account. 

However, when I write this rule I get the "OK" button to highlight, indicating that it's syntactically correct and I click on it to add the rule. However, then I see that it looks different in the SQWRL tab than what I wrote. Some of the "^" signs has been replaced by a "."  The rule ends up looking like this:

FakeAccount(?fa)  .  sqwrl:makeSet(?fas, ?fa) ^ SuspectAccount(?sa) ^ sqwrl:makeSet(?sas, ?sa)  .  sqwrl:difference(?pfa, ?fas, ?sas) -> sqwrl:select(?pfa)

I try editing the rule again and changing the dots to ^ but the same thing happens, some of the  ^  get replaced by dots. BTW, the rule actually has the name of the ontology as a preface to all the non-SQWRL expressions but I see that often and it doesn't seem to effect how things work. 

I tried running the query just to see what happens. I'm able to run the Reasoner after adding this (what I think is malformed) rule but when I hit the "Run" button on the SQWRL tab Protege just hangs, it won't respond at all even to a close and I have to use cntl-alt-del to kill the process. 



Take a look at [1]. In outline, a SQWRL query with collections operators will look as follows:

SWRL Pattern Specification ˚ Collection Construction Clause ˚ Collection Operation Clause → Select Clause

The SQWRL language processor infers the position of the separators with the expectation that all non-SQWRL clauses (SWRL Pattern Specification) come first. If you rewrite your queries to follow that pattern you should be good to go.

Martin




_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: SQWRL Issue

Michael DeBellis-2
Martin, that definitely helped but I think there is something about our ontology that is causing SQWRL to not work correctly as well as SPARQL. I kept trying various versions of the rule and the dots and still couldn't get it to work. So I copied one of the example rules from the SPARQL collections documentation and changed the names as appropriate:

Account(?a) ˚  sqwrl:makeSet(?s, ?a) ˚  sqwrl:size(?size, ?s)  -> sqwrl:select(?size)

The query returned but it said "SQWRL query S2 did not generate any result." When I look at the Individuals in the "Individuals by Class" Tab and the "Individuals by Type (Inferred)" pane it says there are 746 individuals of the Account class. I also tried this on other classes in the ontology, one enumerated class, one defined class, and another primitive class and the result was always the same: even though there are individuals for each class the tab says the query didn't generate any results. 

To test that this has to do with our ontology rather than my version of Protege I took that same rule and changed the name of a class and used it in a small Car ontology I use to demonstrate basic concepts to new users. So the test rule was: 

Car(?a) ˚  sqwrl:makeSet(?s, ?a) ˚  sqwrl:size(?size, ?s)  -> sqwrl:select(?size)

This worked as expected and returned the number 2 which is the number of Cars in the simple example ontology. 

I tested this on the ontology that I sent Csongor and got the same incorrect results so if you or someone can get that ontology from him and just try adding the rule above to count the Accounts you should be able to replicate the problem. Of course, if you have other suggestions of things I should try please let me know. Also, if it's easier, I can resend the problem ontology directly to you or to others if you want, as I said I just don't want to post it to the entire list. Also, if you want me to create a bug report, I'm happy to do that, just wasn't sure which sub-project to put it in so if you could send me a link to the proper project I would create the incident report. 

Thanks for your help,

Michael




On Fri, Jul 12, 2019 at 11:53 AM Martin O'Connor <[hidden email]> wrote:


On Jul 12, 2019, at 11:44 AM, Michael DeBellis <[hidden email]> wrote:

So I thought of an alternative using SQWRL. I created a defined class called SuspectAccount which is defined with the DL above (and works as expected). Then I created the following SQWRL query:

FakeAccount(?fa) ^ sqwrl:makeSet(?fas, ?fa) ^ SuspectAccount(?sa) ^ sqwrl:makeSet(?sas, ?sa) ^ sqwrl:difference(?pfa, ?fas, ?sas) -> sqwrl:select(?pfa)

What I thought this would do is to give me a new set ?pfa (possible fake accounts) that was the set difference between the FakeAccount set and the SuspectAccount set, i.e., those Accounts that are not FakeAccounts but are owned by a user who also owns at least one Fake Account. 

However, when I write this rule I get the "OK" button to highlight, indicating that it's syntactically correct and I click on it to add the rule. However, then I see that it looks different in the SQWRL tab than what I wrote. Some of the "^" signs has been replaced by a "."  The rule ends up looking like this:

FakeAccount(?fa)  .  sqwrl:makeSet(?fas, ?fa) ^ SuspectAccount(?sa) ^ sqwrl:makeSet(?sas, ?sa)  .  sqwrl:difference(?pfa, ?fas, ?sas) -> sqwrl:select(?pfa)

I try editing the rule again and changing the dots to ^ but the same thing happens, some of the  ^  get replaced by dots. BTW, the rule actually has the name of the ontology as a preface to all the non-SQWRL expressions but I see that often and it doesn't seem to effect how things work. 

I tried running the query just to see what happens. I'm able to run the Reasoner after adding this (what I think is malformed) rule but when I hit the "Run" button on the SQWRL tab Protege just hangs, it won't respond at all even to a close and I have to use cntl-alt-del to kill the process. 



Take a look at [1]. In outline, a SQWRL query with collections operators will look as follows:

SWRL Pattern Specification ˚ Collection Construction Clause ˚ Collection Operation Clause → Select Clause

The SQWRL language processor infers the position of the separators with the expectation that all non-SQWRL clauses (SWRL Pattern Specification) come first. If you rewrite your queries to follow that pattern you should be good to go.

Martin



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

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