attardi / deepnl

Deep Learning for Natural Language Processing
GNU General Public License v3.0
457 stars 116 forks source link

Python3 compatibility #28

Closed leondz closed 8 years ago

leondz commented 8 years ago

Hi,

There seem to be a few things breaking deepnl in Python3 during install (not build); for example:


Extracting deepnl-1.3.15-py3.4-linux-x86_64.egg to /usr/local/lib/python3.4/dist-packages
  File "/usr/local/lib/python3.4/dist-packages/deepnl-1.3.15-py3.4-linux-x86_64.egg/deepnl/corpus.py", line 73
    print '\t'.join([item.encode('utf-8') for item in token])
             ^
SyntaxError: invalid syntax

Sorry: TabError: inconsistent use of tabs and spaces in indentation (reader.py, line 181)
  File "/usr/local/lib/python3.4/dist-packages/deepnl-1.3.15-py3.4-linux-x86_64.egg/deepnl/pos_tagger.py", line 28
    print writer.write(self.tag_sequence(sent))
               ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.4/dist-packages/deepnl-1.3.15-py3.4-linux-x86_64.egg/deepnl/utils.py", line 61
    text = re.sub(ur"(?u)(^|\W)[‘’′`']", r'\1"', text)
                                      ^
SyntaxError: invalid syntax
attardi commented 8 years ago

print is a function in python 3. One needs to rewrite all print statements and to make the code compatible with python 2.7 add from future import print_function.

leondz commented 8 years ago

Sure, I don't know if this is the only Py3-incompatible code there

attardi commented 8 years ago

The latest release uses the print() function.