Usage of swrlb:member in owlready2

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

Usage of swrlb:member in owlready2

Gopi
Hi,
I am getting owlready2.rply.LexingError: (None, 200) error while using *member* built-in for list. I am attaching the code snippet below.

Imp().set_as_rule("""Country(?v), hasCity(?v , ?obs), hasCategory(?obs, ?cat), prefLabel(?cat, ?lbl), stringEqualIgnoreCase(?lbl,"New Delhi"),isAbout(?obs,?sem),prefLabel(?sem, ?semlbl), member(?semlbl,["Mueseum","Metro"]) -> UncertainSignificance(?v)""",[har,skos])


Regards,
Gopi
Reply | Threaded
Open this post in threaded view
|

Re: Usage of swrlb:member in owlready2

Jiba
Administrator
Hi,

The problem is in the list definition, here: ["Mueseum","Metro"]. Owlready does not accept list values in the SWRL rule (it expects a variable containing the list).

Are you sure that this syntax is valid? I cannot found example or grammar in the SWRL reference document, and Protégé does not accept it when I tried it.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Usage of swrlb:member in owlready2

Gopi
Hi,
Thanks for the reply. We tried using a variable and still, we were unable to get desired results with the below code snippet.

test1 = ["Mueseum","Metro"]

Imp().set_as_rule("""Country(?v), hasCity(?v , ?obs), hasCategory(?obs, ?cat), prefLabel(?cat, ?lbl), stringEqualIgnoreCase(?lbl,"New Delhi"),isAbout(?obs,?sem),prefLabel(?sem, ?semlbl), member(?semlbl,?test1) -> UncertainSignificance(?v)""",[har,skos])

Regards,
Gopi
Reply | Threaded
Open this post in threaded view
|

Re: Usage of swrlb:member in owlready2

Jiba
Administrator
Hi,

The variable should be an SWRL variable, not a Python one. But defining a list in the ontology is not easy...

Here, I think you have two solutions that are easier than using member:

 * Since there are only 2 elements in the list, you may create two rules, and use stringEqualIgnoreCase. The first rule will test for "Mueseum" and the second for "Metro".

 * If the number of items in the list is bigger, you may create an individual I related to all the list items using a given property P. Then use in SWRL: "P(I, ?semlbl)".

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Usage of swrlb:member in owlready2

Gopi
Hello,
Thanks again for the quick response. Our issue can be addressed using both ways as you suggested.

Regards,
Gopi