How to use SWRL + Pellet + SPARQL

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

How to use SWRL + Pellet + SPARQL

IWilliams
I have the following classes:
   *Web_Attack
           InputValidation
                     XSS
                     XSRF
           ParameterTampering*
    Flow
with object property:
  affactedBy (Flow --> Web_Attack)

I create some individuals:
    *XSS32 (XSS)
    XSS198 (XSS)
    Flow10 (Flow)*

I create some SWRL rules:
  *Flow(?f) ^ InputValidation(?x) -> affectedBy(?f, ?x)
  InputValidation(?i) -> Web_Attack(?i)
  XSS(?x) -> InputValidation(?x)*


I tried the following SPARQL:

SELECT ?flow
        WHERE { ?flow uc:affectedBy ?attack.}

I would expect it to return:
      XSS32
      XSS198

but nothing is showing. I am also running the Pellet reasoner

How do I get the inferred facts that SWRL created to show up in the SPARQL
query results?

I am trying to build a recommender engine in python using Owlready2, so I
want to write SWRL rules and then have SPARQL show me the results.

 



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to use SWRL + Pellet + SPARQL

Michael DeBellis-2
I think your problem is that the SPARQL tab in Protege doesn't support a reasoner. So if you have inferred values from the reasoner they won't be visible in the SPARQLTab even if you run the reasoner. I just had the same problem a few days ago. FYI, the Allegra suite from Franz has a SPARQL implementation that does support a reasoner. We are using it for a project I'm working on. But there is an easy  solution for you. All you need to do is to save all the inferences of the reasoner as if they were asserted by the user. There is an option for that in Protege called "File>Export inferred axioms as ontology".  It's pretty self explanatory but there is one issue with the saved file, I wrote up a short explanation of that on my blog: https://www.michaeldebellis.com/post/export-inferred-axioms   

Hope that helps.
Cheers,
Michael

On Thu, Feb 6, 2020 at 1:00 PM IWilliams <[hidden email]> wrote:
I have the following classes:
   *Web_Attack
           InputValidation
                     XSS
                     XSRF
           ParameterTampering*
    Flow
with object property:
  affactedBy (Flow --> Web_Attack)

I create some individuals:
    *XSS32 (XSS)
    XSS198 (XSS)
    Flow10 (Flow)*

I create some SWRL rules:
  *Flow(?f) ^ InputValidation(?x) -> affectedBy(?f, ?x)
  InputValidation(?i) -> Web_Attack(?i)
  XSS(?x) -> InputValidation(?x)*


I tried the following SPARQL:

SELECT ?flow
        WHERE { ?flow uc:affectedBy ?attack.}

I would expect it to return:
      XSS32
      XSS198

but nothing is showing. I am also running the Pellet reasoner

How do I get the inferred facts that SWRL created to show up in the SPARQL
query results?

I am trying to build a recommender engine in python using Owlready2, so I
want to write SWRL rules and then have SPARQL show me the results.





--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to use SWRL + Pellet + SPARQL

IWilliams
Thank you for this information. I dont know if you are familiar with
Owlready2. Owlready2 will populate the ontology for me. So, it would be
better if I use api that can query the ontology for me. I am building a web
application that recommend the SPARQL results to the users.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to use SWRL + Pellet + SPARQL

Michael DeBellis-2
Sorry, I misunderstood, I thought you were working from within Protege. I've never used Owlready2 but I think I understand what it does. I know AllegroGraph from Franz.com works well with Python and it has a SPARQL engine that can see reasoner inferences so if you have the budget for a commercial product I would recommend looking at it. It also provides a triple store and a very powerful knowledge graph environment. But I don't know of a free tool that will do what you need, perhaps someone else on the list may have some ideas. 

On Thu, Feb 6, 2020 at 8:41 PM IWilliams <[hidden email]> wrote:
Thank you for this information. I dont know if you are familiar with
Owlready2. Owlready2 will populate the ontology for me. So, it would be
better if I use api that can query the ontology for me. I am building a web
application that recommend the SPARQL results to the users.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to use SWRL + Pellet + SPARQL

Megan Katsumi
I'm not sure whether owlready2 supports SWRL, but you might try posing this question with a bit more detail on their forum: http://owlready.8326.n8.nabble.com. They are quite helpful.
Best,
Megan

On Fri, Feb 7, 2020 at 1:04 AM Michael DeBellis <[hidden email]> wrote:
Sorry, I misunderstood, I thought you were working from within Protege. I've never used Owlready2 but I think I understand what it does. I know AllegroGraph from Franz.com works well with Python and it has a SPARQL engine that can see reasoner inferences so if you have the budget for a commercial product I would recommend looking at it. It also provides a triple store and a very powerful knowledge graph environment. But I don't know of a free tool that will do what you need, perhaps someone else on the list may have some ideas. 

On Thu, Feb 6, 2020 at 8:41 PM IWilliams <[hidden email]> wrote:
Thank you for this information. I dont know if you are familiar with
Owlready2. Owlready2 will populate the ontology for me. So, it would be
better if I use api that can query the ontology for me. I am building a web
application that recommend the SPARQL results to the users.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
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


--
Megan Katsumi, PhD, MASc
Postdoctoral Fellow
University of Toronto

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

Re: How to use SWRL + Pellet + SPARQL

Lorenz Buehmann
In reply to this post by IWilliams
Not sure what you're doing now. You're using owlready2 for what? And how do you run SPARQL then? Those are totally different things. owlready2 has no built-in SPARQL engine. Moreover, SPARQL with inference is mostly limited by the entailment regime by the SPARQL engine.

The most obvious way would be to materialize inferences and then do the SPARQL stuff. All engines do either forward chaining or have to do query rewriting. Both are not fun. There is also no SPARQL engine I'm aware of that does support SWRL except for Stardog which used in-memory Pellet under the hood with full OWL2 DL support. Clearly, this is never as fast as some rule-based reasoning profile, like RDFS, OWL RL, etc.

Also, why this question on the Protege mailing list?
Thank you for this information. I dont know if you are familiar with
Owlready2. Owlready2 will populate the ontology for me. So, it would be
better if I use api that can query the ontology for me. I am building a web
application that recommend the SPARQL results to the users.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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

Re: How to use SWRL + Pellet + SPARQL

IWilliams
Hi,

I was trying out swrl, sparql and pellet in Protege, where I want to get
inferred facts based on swrl rules. Next, I would use sparql to get the
inferred facts, but I was told that the sparql tab does not support
inference. If the setup (swrl, sparql and pellet) in my first post worked in
Protege, I would then try it in Owlready2.  The current research project
that I am working on has to programmatically modify an ontology using python
and query inferred facts using Sparql or sqwrl and then display the results
in a web interface (Django). I am only aware of Owlready2 that can
programmatically modify an OWL ontology similarly to Protege.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: How to use SWRL + Pellet + SPARQL

samsontu

On Feb 8, 2020, at 5:37 AM, IWilliams <[hidden email]> wrote:

Hi,

I was trying out swrl, sparql and pellet in Protege, where I want to get
inferred facts based on swrl rules. Next, I would use sparql to get the
inferred facts, but I was told that the sparql tab does not support
inference. If the setup (swrl, sparql and pellet) in my first post worked in
Protege, I would then try it in Owlready2.  The current research project
that I am working on has to programmatically modify an ontology using python
and query inferred facts using Sparql or sqwrl and then display the results
in a web interface (Django). I am only aware of Owlready2 that can
programmatically modify an OWL ontology similarly to Protege.


1. Protege 5.5 has two SPARQL query tabs: the default SPARQL Query tab does not support inference; the alternative Snap SPARQL Query Tab does (although Snap SPARQL does not support the full set of SPARQL 1.1 constructs).
2. Has anyone tried Jython as way to access the OWL API in a Python environment? (Granted that Jython implements only Python 2.7. Still, it may be a way to programmatically access the full power of OWL API in a pythonic environment.)

With best regards,
Samson


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