Open lucailvec opened 3 years ago
@lucailvec this project is, as I understand, no longer active and I suggest you try https://github.com/goodmami/wn/ instead. I saw this issue and tried it out there, but sure enough deep copy didn't work because each object contained a pointer to a shared database connection. I've restructured the code (not yet released) so this is no longer the case:
>>> import copy
>>> import wn
>>> synsets = wn.synsets("try")
>>> synset = synsets[0]
>>> synset
Synset('ewn-02535833-v')
>>> synset_copy = copy.deepcopy(synset)
>>> synset_copy is synset
False
>>> synset_copy == synset
True
>>> import pickle
>>> pickle.loads(pickle.dumps(synset))
Synset('ewn-02535833-v')
While this works, it's still not portable across machines because these objects store and use a row identifier to the backend SQL database, and this identifier is not guaranteed to be the same for different builds of the database (see goodmami/wn#84). Can you explain your needs a bit? Is the dumped transformer model distributed to others, or is it used on a single machine?
I hope to either remove the need to store the rowids or to create a custom deepcopy method to get around it, but in the meantime the current code might solve your immediate problem.
Hello,
Scenario: develop a custom transformer that work under Sklearn framework. This transformer is required to be dumped in/out by Sklearn framework. This transformer have a reference to an inverted index that use synset as the domain of a mapping function to integer.
Problem:
it breaks by showing:
So a custom deepcopy method it's very appriacetd.
Best regard
Luca