0

I've been trying to setup hunpos on my windows system but am experiencing some issues.

The error i get is

File "C:\Users\a\Desktop\x.py", line 25, in <module>
ht = HunposTagger('english.model')
File "C:\Python27-32\lib\site-packages\nltk-2.0.1rc4-py2.7-win32.egg\nltk\tag\hunpos.py", line 84, in __init__
verbose=verbose)
File "C:\Python27-32\lib\site-packages\nltk-2.0.1rc4-py2.7-win32.egg\nltk\internals.py", line 526, in find_binary
url, verbose)
 File "C:\Python27-32\lib\site-packages\nltk-2.0.1rc4-py2.7-win32.egg\nltk\internals.py", line 510, in find_file
raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError:   ===========================================================================
NLTK was unable to find the hunpos-tag file!
Use software specific configuration paramaters or set the HUNPOS environment variable.

Searched in:
- C:\Users\a\
- .
- /usr/bin
- /usr/local/bin
- /opt/local/bin
- /Applications/bin
- C:\Users\a/bin
- C:\Users\a/Applications/bin

I'm guessing there's a bug in nltk's internals.py but not sure how to fix it. I added os.getcwd() to hunpos_paths in hunpos.py but it doesn't help.

Does anyone know why this is happening?

Thanks

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
Duke
  • 348
  • 1
  • 6
  • 16
  • That's a pretty nice error message. What is this HUNPOS env var of which they speak? Have you set that? – mechanical_meat Mar 28 '12 at 15:03
  • it's in hunpos.py `self._hunpos_bin = find_binary(...env_vars=('HUNPOS', 'HUNPOS_HOME'), searchpath=hunpos_paths...)` I set `HUNPOS` in my env var as well. – Duke Mar 28 '12 at 15:06
  • i actually changed internals.py to print the `filename` and not `name` as described here `https://github.com/nltk/nltk/issues/217` – Duke Mar 28 '12 at 15:08
  • `>>> config_hunpos-tag('C:\Users\a\') Traceback (most recent call last): File "", line 1, in NameError: name 'config_hunpos_tag' is not defined` – Duke Mar 28 '12 at 15:42

3 Answers3

0

Did you compile hunpos-tag on your own? If not, and you downloaded the binary from google code or any other place, it cannot be the case that the runnable is actually an exe file (I have no idea whether exe extension is needed by windows for a file to be executable or not), and hunpos.py calls find_binary() to locate hunpos-tag, but not hunpos-tag.exe? I don't know how find_binary() works, but this may be the problem.

zseder
  • 1,099
  • 2
  • 12
  • 15
0
from nltk.tag.hunpos import HunposTagger
ht = HunposTagger('english.model', 'hunpos-1.0-win/hunpos-tag.exe')
ht.tag('What is the airspeed of an unladen swallow ?'.split())
ht.close()

You need to set hunpos files paths as arguments.

cyan
  • 53
  • 2
  • 6
0

Do you have the file english.model? If you do, set the environment variable HUNPOS to the directory that contains it, and run python again. If you still get an error, check that the directory appears in the list of locations searched.

alexis
  • 48,685
  • 16
  • 101
  • 161
  • If it's not searching in the directory you gave it, it's not yet seeing HUNPOS. Check for yourself by printing `os.environ['HUNPOS']` from the interpreter prompt (after `import os`) – alexis Mar 28 '12 at 16:08
  • Is the error saying it searched the directory in question? If yes, there's only one more thing I can think of (I don't have hunpos): Try setting HUNPOS to the full name of the model, including the filename. – alexis Mar 28 '12 at 16:29
  • the error says it's unable to find the hunpos-tag file (which is an executable for win platforms). i tried setting it to the tag file and then the model file but neither worked – Duke Mar 28 '12 at 16:41
  • Read the whole error, it tells you which directories it searched in. – alexis Mar 28 '12 at 16:43
  • yes, i know. i've tried everything suggested here and more but don't know why i still have the error. – Duke Mar 28 '12 at 16:49
  • So does it search in the directory specified by HUNPOS, or doesn't it? – alexis Mar 29 '12 at 13:19