Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.min does not return expected values for cardinality >1 #35

Open
liamhuber opened this issue Feb 13, 2023 · 0 comments
Open

.min does not return expected values for cardinality >1 #35

liamhuber opened this issue Feb 13, 2023 · 0 comments

Comments

@liamhuber
Copy link

I'm trying to use the min method to count the number of properties (of a particular type) on an object, but I find that counting fails silently for all cardinalities >1. ("silently" = gives unexpected results with no python or java error).

Example:

import owlready2 as owl

for n in [1, 2, 3]:
    onto = owl.get_ontology(f"file://mwe{n}.owl")

    with onto:
        class MyThing(owl.Thing): pass
        class MyProperty(owl.Thing): pass

        class has_for_property(MyThing >> MyProperty):
            class_property_type = "some"
            python_name = "properties"

        class HasAtLeastNProperties(MyThing):
            defined_class = True
            equivalent_to = [MyThing & has_for_property.min(n, MyProperty)]


    has_none = MyThing("none", properties=[])
    has_one = MyThing("one", properties=[MyProperty()])
    has_two = MyThing("two", properties=[MyProperty(), MyProperty()])
    has_three = MyThing("three", properties=[MyProperty(), MyProperty(), MyProperty()])

    owl.close_world(onto.MyThing)
    owl.sync_reasoner_pellet(
        infer_property_values=True, infer_data_property_values=True, debug=0
    )

    print(f"THING, HAS AT LEAST {n} PROPERTIES")
    for thing in [has_none, has_one, has_two, has_three]:
        print('\t', thing.name, HasAtLeastNProperties in thing.INDIRECT_is_a)

Actual output:

THING, HAS AT LEAST 1 PROPERTIES
	 none False
	 one True
	 two True
	 three True
THING, HAS AT LEAST 2 PROPERTIES
	 none False
	 one False
	 two False
	 three False
THING, HAS AT LEAST 3 PROPERTIES
	 none False
	 one False
	 two False
	 three False

Expected output:

THING, HAS AT LEAST 1 PROPERTIES
	 none False
	 one True
	 two True
	 three True
THING, HAS AT LEAST 2 PROPERTIES
	 none False
	 one False
	 two True
	 three True
THING, HAS AT LEAST 3 PROPERTIES
	 none False
	 one False
	 two False
	 three True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant