AlexKuhnle / ShapeWorld

MIT License
58 stars 18 forks source link

Conflict between mode "relational" and negated relation / implication #16

Closed RobinDelearde closed 4 years ago

RobinDelearde commented 4 years ago

With mode agreement and relational ('-t agreement -n relational'),

  1. with "negation" to None/True in config file, set_realizer for captioners/negation_relation.py falls in error in "assert -1 in realizer.relations['negation']": AssertionError ex: python generate.py -d examples/test1 -U -t agreement -n relational -i 1 -M -H

  2. with "negation" to False in config file (or if using python -O), correct for captioners/regular_type.py falls in error in "sub_predication.implies(predicate=caption)": AttributeError: 'generator' object has no attribute 'implies' ex1: python -O generate.py -d examples/test1 -U -t agreement -n relational -i 1 -M -H ex2: python generate.py -d examples/test2 -U -t agreement -n relational -c configs/agreement/relational/spatial_twoshapes.json -i 100 -M -H -G

NB1: obtained after correction of captions/pragmatical_predication.py (line 62: yield predication.get_sub_predications()) NB2: deleting line 62 in captions/pragmatical_predication.py seems to oust this issue.

ShapeWorld_issue.txt

AlexKuhnle commented 4 years ago

The first issue should hopefully be fixed now (at least in the negation_relation.py file). Let me know if there are still problems.

Regarding the second issue, that is unexpected. Which Python version are you using? yield from should work fine with 3.3+. Or otherwise, could you iterate through the "generator" and print what and how many items are in there (by inserting a print statement before the yield/yield from)?

RobinDelearde commented 4 years ago

Ok thanks. The first issue no longer occurs with the correction (and then falls in the second issue with Python 2).

The second issue only concerns Python 2 indeed. It's ok with Python 3 and "yield from" in pragmatical_predication.py as in your version. When printing with Python 3 and "yield from", I get 1 / few (2-10) / many (sometimes >400) lines {agreeing: X, ambiguous: Y, disagreeing: Z}. When printing with Python 2 and just "yield", I usually get only 1 line, sometimes more (up to 12 in 20 tests) before the error Traceback. Replacing the "yield from" line by a traditional for loop solves the problem.