owlready2.rply.LexingError: (None, 0) while setting a rule

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

owlready2.rply.LexingError: (None, 0) while setting a rule

jfwei1992
Hi all,

I am trying to load an ontology that contains multiple namespaces and insert some rules into it. I called method set_as_rule() then I was given an error:

owlready2.rply.LexingError: (None, 0)

A specific rule I am trying to put in is '_is.TiplocLocation(?c), rw.currentDewPoint(?c, ?d), rw.currentTemp(?c, ?e), greaterThan(?d, ?e) -> rw.hasPotentialLowAdhesion(?c, True)'

I guess it is because the appearance of multiple namespaces in one rule as the tutorial only demonstrates creating rules for one namespace.

Is there anything I can do to solve this? Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: owlready2.rply.LexingError: (None, 0) while setting a rule

Jiba
Administrator
Hi,

If there are several namespaces, you cannot indicate them with dot (e.g. currentDewPoint instead of rw.currentDewPoint). Then, set_as_rules accepts a second parameters, which is a list of Owlready namepaces (or ontologies). For example:

Imp().set_as_rule("TiplocLocation(?c), currentDewPoint(?c, ?d)...", [_is, rw])

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: owlready2.rply.LexingError: (None, 0) while setting a rule

jfwei1992
Hi Jiba,

Thank you very much! I will try it asap.

Reply | Threaded
Open this post in threaded view
|

Re: owlready2.rply.LexingError: (None, 0) while setting a rule

jfwei1992
In reply to this post by Jiba
Hi Jiba,

Thanks to your advice, it works now. Additionally, is there any way to list inferred triples after run the reasoner?

Kind regards,

Jin
Reply | Threaded
Open this post in threaded view
|

Re: owlready2.rply.LexingError: (None, 0) while setting a rule

Jiba
Administrator
Hi,

You can put the inferred triples in a separate ontology (using the with ontology:... syntax), and then save this ontology as NTriples to obtain the RDF triple (or use ontology.graph.dump() to display them in terminal).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: owlready2.rply.LexingError: (None, 0) while setting a rule

jfwei1992
Thank you very much. That is very useful!