alvations / pywsd

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

installation of pywsd via pip #28

Closed AvinashReddyRangu closed 7 years ago

AvinashReddyRangu commented 7 years ago

hi how to install pywsd for python 3 via pip? I am getting error when i run from pywsd.lesk import simple_lesk ImportError: No module named 'lesk'

alvations commented 7 years ago

Ah, absolute vs local import issues. I'll be fixing that when evening comes.

AvinashReddyRangu commented 7 years ago

Hi I am using python 3.5.2 i have installed pywsd via pip install pywsd ran >>> import pywsd Traceback (most recent call last): File "", line 1, in File "C:\Users\Mythri\Anaconda3\lib\site-packages\pywsd__init__.py", line 9, in import lesk ImportError: No module named 'lesk'

when i run from pywsd.lesk import simple_lesk

i get this error Traceback (most recent call last): File "F:/Anthem/pywsd1.py", line 2, in from pywsd.lesk import simple_lesk File "C:\Users\Mythri\Anaconda3\lib\site-packages\pywsd__init__.py", line 9, in import lesk ImportError: No module named 'lesk'

please help me to install it

alvations commented 7 years ago

@AvinashReddyRangu it won't work for Python3 until I get it patched up tonight =)

I should work fine for Python2 though. Sorry for the slight delay.

alvations commented 7 years ago

It should be fixed now. Please do:

pip3 install -U pywsd

On my machine:

$ pip3 install pywsd
Collecting pywsd
  Downloading pywsd-1.0.2.tar.gz
Requirement already satisfied: nltk in /usr/local/lib/python3.5/site-packages (from pywsd)
Requirement already satisfied: numpy in /usr/local/lib/python3.5/site-packages (from pywsd)
Requirement already satisfied: six in /usr/local/lib/python3.5/site-packages (from nltk->pywsd)
Building wheels for collected packages: pywsd
  Running setup.py bdist_wheel for pywsd ... done
  Stored in directory: /Users/liling.tan/Library/Caches/pip/wheels/45/2b/e5/e965d8cb30c8e654b06fd5b9b8ce9ee63cca8d291def3476fe
Successfully built pywsd
Installing collected packages: pywsd
Successfully installed pywsd-1.0.2

$ python3
Python 3.5.2 (default, Oct 11 2016, 04:59:56) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywsd
>>> from pywsd import disambiguate
>>> from pywsd.lesk import simple_lesk
>>> sent = 'I went to the bank to deposit my money'
>>> ambiguous = 'bank'
>>> answer = simple_lesk(sent, ambiguous, pos='n')
>>> answer
Synset('bank.n.09')
>>> disambiguate('I went to the bank to deposit my money')
[('I', None), ('went', Synset('run_low.v.01')), ('to', None), ('the', None), ('bank', Synset('bank.n.09')), ('to', None), ('deposit', Synset('deposit.v.02')), ('my', None), ('money', Synset('money.n.03'))]
>>> from pywsd.similarity import max_similarity as maxsim
>>> disambiguate('I went to the bank to deposit my money', algorithm=maxsim, similarity_option='wup', keepLemmas=True)
[('I', 'i', None), ('went', 'go', Synset('sound.v.02')), ('to', 'to', None), ('the', 'the', None), ('bank', 'bank', None), ('to', 'to', None), ('deposit', 'deposit', Synset('deposit.v.02')), ('my', 'my', None), ('money', 'money', None)]
AvinashReddyRangu commented 7 years ago

Thanks for the quick response . Its working now

DStickley commented 4 years ago

I'm getting the same error with an up to date version of pywsd:

AttributeError Traceback (most recent call last)

in () ----> 1 import pywsd /usr/local/lib/python3.6/dist-packages/pywsd/__init__.py in () 31 from pywsd.allwords_wsd import disambiguate 32 ---> 33 pywsd.lesk.simple_lesk('This is a foo bar sentence', 'bar') 34 print('took {} secs.'.format(time.time()-start), file=sys.stderr) AttributeError: module 'pywsd' has no attribute 'lesk' I'm trying to run this on google colab on a python 3 runtime (python3.6.8)
alvations commented 4 years ago

@DStickley Thank you for reporting the issue!

Please try to upgrade the pywsd again, pip install -U pywsd, you should see version 1.2.4 that solves this issue for Python 3.6

Example: https://colab.research.google.com/drive/1X8ulJfd5Mqy4KGPZTL5A5vAcsA5sJ4BU

ruolanyang commented 3 years ago

i get the error : ImportError: cannot import name 'WordNet' when trying to "from pywsd.lesk import simple_lesk"

mhelal commented 2 years ago

i get the error : ImportError: cannot import name 'WordNet' when trying to "from pywsd.lesk import simple_lesk"

I am getting the same error, please fix