我一直在尝试在我的windows系统上设置hunpos,但遇到了一些问题。
我得到的错误是
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我猜nltk的internals.py中有一个bug,但不确定如何修复它。我在hunpos.py中将os.getcwd()添加到hunpos_paths中,但它没有帮助。
有人知道为什么会这样吗?
谢谢
发布于 2012-03-28 23:54:14
你有english.model文件吗?如果需要,请将环境变量HUNPOS设置为包含它的目录,然后再次运行它。如果仍然出现错误,请检查该目录是否出现在搜索的位置列表中。
发布于 2012-04-23 21:28:06
你是自己编译hunpos-tag的吗?如果不是,并且你从google code或任何其他地方下载了二进制文件,这不可能是可运行文件实际上是一个可执行文件(我不知道windows是否需要可执行文件的扩展名),并且hunpos.py调用find_binary()来定位hunpos-tag,而不是hunpos-tag.exe?我不知道find_binary()是如何工作的,但这可能是问题所在。
发布于 2014-09-09 03:09:36
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()您需要将hunpos文件路径设置为参数。
https://stackoverflow.com/questions/9910194
复制相似问题