OpenNMT / OpenNMT-py

Open Source Neural Machine Translation and (Large) Language Models in PyTorch
https://opennmt.net/
MIT License
6.75k stars 2.25k forks source link

AttributeError: 'int' object has no attribute 'rstrip' #437

Closed aotemandess closed 6 years ago

aotemandess commented 6 years ago

Thanks for releasing your code! While running the code for 'WMT'16 Multimodal Translation: Multi30k (de-en)- Preprocess the data', it has"AttributeError: 'int' object has no attribute 'rstrip'":

**root@qzw:/home/qzw123/wangyuan/OpenNMT-py-master#** python preprocess.py -train_src data/multi30k/train.en.atok -train_tgt data/multi30k/train.de.atok -valid_src data/multi30k/val.en.atok -valid_tgt data/multi30k/val.de.atok -save_data data/multi30k.atok.low -lower
Preparing training ...
Building Training...
Traceback (most recent call last):
  File "preprocess.py", line 94, in <module>
    main()
  File "preprocess.py", line 71, in main
    dynamic_dict=opt.dynamic_dict)
  File "/home/qzw123/wangyuan/OpenNMT-py-master/onmt/IO.py", line 361, in __init__
    filter_pred if use_filter_pred else None
  File "/root/anaconda2/lib/python2.7/site-packages/torchtext/data/dataset.py", line 40, in __init__
    examples = list(filter(filter_pred, examples))
  File "/home/qzw123/wangyuan/OpenNMT-py-master/onmt/IO.py", line 352, in <genexpr>
    for ex_values in example_values)
  File "/root/anaconda2/lib/python2.7/site-packages/torchtext/data/example.py", line 59, in fromlist
    setattr(ex, name, field.preprocess(val.rstrip('\n')))
AttributeError: 'int' object has no attribute 'rstrip'**
JianyuZhan commented 6 years ago

Have checked the torchtext code, this seems a bug: https://github.com/pytorch/text/pull/145.

Please install the torchtext 0.1.1 and see if it fixes your problem.