有谁知道如何在 nltk 上配置 hunpos 包装类?
我已经尝试了以下代码并安装了 来自 http://code.google.com/p/hunpos/downloads/list
英语-wsj-1.0
hunpos-1.0-linux.tgz
我已将文件提取到“~/”目录中
,当我尝试以下 python 代码时:
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())
我收到以下错误
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
如何在 python 中配置 hunpos?我需要输入哪个Python命令?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你已经非常接近解决方案了。将 hunpos-tag 可执行文件移动到 /home/ubi/bin ,然后它应该能够找到它。当我第一次尝试使用 hunpos 时,这也给我带来了一些麻烦。
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.