problem appeared in SWRL (answered)

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

problem appeared in SWRL (answered)

William
This post was updated on .
I set a rule: if a planet travels around a celestial, then the celestial is a star. But I got an error "caused by: java.lang.UnsupportedOperationException: Builtin using unsafe variables: [round([?p, ?s])]". Following is the code. It is my first time to use SWRL. I thought it was as easy as first-order logic, or Prolog. But I failed.

Did I make any mistake?


test = get_ontology("http://test.org/test.owl")


with test:
    class Celestial(Thing):
        pass
    class round(Celestial >> Celestial):
        pass

    class Planet(Celestial):
        pass

    class Star(Celestial):
        pass

    earth = Planet('earth')
    sun = Celestial('sun')

    earth.round = [sun]

    rule = Imp()
    # Planet.is_a.append(round.only(Star))
    rule.set_as_rule("Planet(?p), Celestial(?s), round(?p, ?s) -> Star(?s)")


close_world(test)

sync_reasoner_pellet(infer_property_values = True, infer_data_property_values = True)
print(sun.INDIRECT_is_instance_of)  # I hope that I can get Star in the list.
Reply | Threaded
Open this post in threaded view
|

Re: problem appeared in SWRL

Jiba
Administrator
Hi,

The problem is that "round" is a reserved builtin in SWRL.

The easy solution is to rename your property, for example "is_round".
The more complex one is to create you SWRL rule by hand, one atom at a time.

Jiba