Does anyone know how to configure the hunpos wrapper class on nltk?
Asked Answered
O

1

4

i've tried the following code and installed from http://code.google.com/p/hunpos/downloads/list

english-wsj-1.0

hunpos-1.0-linux.tgz

i've extracted the file onto '~/' directory

and when i tried the following python code:

import nltk
from nltk.tag import hunpos
from nltk.tag.hunpos import HunposTagger
import os, sys, re, glob
cwd = os.getcwd()

for infile in glob.glob(os.path.join(cwd, '*.txt')):
    (PATH, FILENAME) = os.path.split(infile)
    read = open(infile)
    ht = HunposTagger('english.model')
    ht.tag(read.readline())

i get the following error

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/tag/hunpos.py", line 46, in __init__
    verbose=verbose)
  File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/internals.py", line 503, in find_binary
    raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError: 

===========================================================================
  NLTK was unable to find the hunpos-tag executable!  Use
  config_hunpos-tag() or set the HUNPOS environment variable.

    >>> config_hunpos-tag('/path/to/hunpos-tag')

  Searched in:
    - .
    - /usr/bin
    - /usr/local/bin
    - /opt/local/bin
    - /Applications/bin
    - /home/ubi/bin
    - /home/ubi/Applications/bin

  For more information, on hunpos-tag, see:
    <http://code.google.com/p/hunpos/>
===========================================================================
>>> config_hunpos-tag('~/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'config_hunpos' is not defined

how do i configure hunpos in python? which python command do i need to enter?

Orchard answered 23/2, 2011 at 13:15 Comment(0)
D
4

You're very close to the solution. Move the hunpos-tag executable to /home/ubi/bin and it should be able to find it then. This caused me some trouble too when I was first trying to use hunpos.

Danica answered 23/2, 2011 at 22:32 Comment(1)
yep the hunpos needs to be moved to either of those dir. thanks!Orchard

© 2022 - 2024 — McMap. All rights reserved.