alvations / pywsd

Python Implementations of Word Sense Disambiguation (WSD) Technologies.
MIT License
744 stars 132 forks source link

random.seed issue #37

Closed viraja1 closed 6 years ago

viraja1 commented 6 years ago

Right now in baseline.py, the seed is set for the global Random() instance. Therefore the seed will be shared between all other imports of random and will cause issues if the person using pywsd is not aware of it.

https://github.com/alvations/pywsd/blob/d650c4ecb9dac7078a977f045e0d4ab092f648d3/pywsd/baseline.py#L11

Python random Documentation - https://docs.python.org/2/library/random.html

The functions supplied by this module are actually bound methods of a hidden instance of the random.Random class. You can instantiate your own instances of Random to get generators that don’t share state.

import random
custom_random = random.Random(0)
alvations commented 6 years ago

@viraja1 Thanks for raising this issue! The latest version pywsd>=1.1.2 patched this =)