nltk/nltk — Issue #130: ProbabilisticTree breaks when you copy.deepcopy it
Author: alexrudnick
Created: 2012-01-17 06:26:45+00:00
State: open

What steps will reproduce the problem?

>>> from nltk.tree import *
>>> tr = ProbabilisticTree("TOP", ["N"], prob=0.3)
>>> import copy
>>> copy.deepcopy(tr)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.6/copy.py", line 323, in _reconstruct
y = callable(*args)
File "/usr/lib/python2.6/copy_reg.py", line 93, in __newobj__
return cls.__new__(cls, *args)
TypeError: __new__() takes at least 2 arguments (1 given)
>>>

What is the expected output? What do you see instead?

Should return a new ProbabilisticTree object, but it throws a TypeError instead!

Please use labels and text to provide additional information.

Will investigate further -- but the __new__ class method in ProbabilisticTree takes one more argument than the one in Tree -- could that have something to do with it? Regular Tree objects can be copy.deepcopy'd.

Migrated from http://code.google.com/p/nltk/issues/detail?id=613