AlexKuhnle / ShapeWorld

MIT License
58 stars 18 forks source link

TypeError in shapeworld/realizers/dmrs/dmrs.py #2

Closed willanxywc closed 6 years ago

willanxywc commented 6 years ago

Hello~ I ran the demo to generate dataset: python generate.py -d examples/agreement/multishape -U -t agreement -n multishape -i 10 -p 0.1 -M -H then got error:

File "generate.py", line 142, in <module>
    generated = dataset.generate(n=args.instances, mode=mode, noise_range=args.pixel_noise, include_model=args.include_model, alternatives=True)
  File "/home/jysen/code/shapeworld/shapeworld/dataset.py", line 773, in generate
    captions = self.caption_realizer.realize(captions=captions)
  File "/home/jysen/code/shapeworld/shapeworld/realizers/dmrs/realizer.py", line 217, in realize
    mrs_list.append(dmrs.get_mrs() + '\n')
  File "/home/jysen/code/shapeworld/shapeworld/realizers/dmrs/dmrs.py", line 146, in get_mrs
    for nodeid in labels[lbl]:
TypeError: 'int' object is not iterable

I m new to dmrs and can't figure this out. I m using python2.7 with the latest shapeworld, and the pydmrs in https://github.com/delph-in/pydmrs/tree/python2 BTW there are lots of bugs in the https://github.com/delph-in/pydmrs/tree/master. For example in mapping/paraphrase.py. And the v1.6 pydmrs from pip doesn' t even have paraphrase.py which is frequently called in the shapeword/realizers.

AlexKuhnle commented 6 years ago

Hi @willanxywc,

I just fixed this bug, something to do with how the labels dict was iterated, which worked in Python3 (what I'm using), but not in Python2. Hope that solves the problem.

Yes, this project started a Python2-compatible branch of pydmrs and by now contains a few fixes that I encountered on the way. They will be integrated into pydmrs at some point. If you start using pydmrs and you need these features, let me know.

AlexKuhnle commented 6 years ago

(Reopen if you still encounter the problem.)

willanxywc commented 6 years ago

Hi @AlexKuhnle Thx for your timely fix~ but which version/branch of pydmrs should I use if switch to python3? https://github.com/delph-in/pydmrs/tree/python2 this is for python2 and https://github.com/delph-in/pydmrs/tree/master seems to contain some bugs. do you have a proper version of pydmrs to run the shapeworld?

willanxywc commented 6 years ago

Hi @AlexKuhnle the python2 branch of pydmrs seems fine with python3~

AlexKuhnle commented 6 years ago

The 'python2' branch, since it is just in addition python2-compatible in the features that ShapeWorld requires, but it also works with Python3. Hence this is the 'proper' version of pydmrs for ShapeWorld for now. And some point they will probably be merged again, or since Python2 will soon be dropped anyway, I will drop Python2-support as well.

Did you still encounter problems when using it with Python2?

willanxywc commented 6 years ago

hi~I didn't try with python2 since you said "I just fixed this bug, something to do with how the labels dict was iterated, which worked in Python3 (what I'm using), but not in Python2. " so i just switched to python 3.

AlexKuhnle commented 6 years ago

Cool, if switching to Python3 is no problem, that's in general more bug-free, I guess. :+1: