微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python – 有谁知道如何在nltk上配置hunpos包装器类?

我已经尝试了以下代码并安装
http://code.google.com/p/hunpos/downloads/list

english-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命令?

解决方法:

你非常接近解决方案.将hunpos-tag可执行文件移动到/ home / ubi / bin,它应该能够找到它.当我第一次尝试使用hunpos时,这也给我带来了一些麻烦.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐