alvations / pywsd

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

simple_lesk bug #57

Open r-reilly opened 5 years ago

r-reilly commented 5 years ago

When running from pywsd.lesk import cached_signatures, simple_lesk

I get the following error

Warming up PyWSD (takes ~10 secs)... Traceback (most recent call last): File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2897, in get_loc return self._engine.get_loc(key) File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'bar.n.04'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pywsd/init.py", line 33, in pywsd.lesk.simple_lesk('This is a foo bar sentence', 'bar') File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pywsd/lesk.py", line 251, in simple_lesk from_cache=from_cache) File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pywsd/lesk.py", line 226, in simple_signatures from_cache=from_cache) File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pywsd/lesk.py", line 123, in signatures from_cache=from_cache) File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pywsd/lesk.py", line 48, in synset_signatures return synset_signatures_from_cache(ss, hyperhypo, adapted, original_lesk) File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pywsd/lesk.py", line 35, in synset_signatures_from_cache return cached_signatures[ss.name()][signature_type] File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pandas/core/frame.py", line 2980, in getitem indexer = self.columns.get_loc(key) File "/Users/rreilly/anaconda3/envs/-/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2899, in get_loc return self._engine.get_loc(self._maybe_cast_indexer(key)) File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'bar.n.04'

alvations commented 5 years ago

@r-reilly seemed like the synset signatures were off when the wn packaged was updated. Could you try upgrading pip install -U pywsd then try again? It should work now =)