有谁知道如何在nltk上配置hunpos包装器类? [英] Does anyone know how to configure the hunpos wrapper class on nltk?

查看:74
本文介绍了有谁知道如何在nltk上配置hunpos包装器类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

english-wsj-1.0

english-wsj-1.0

hunpos-1.0-linux.tgz

hunpos-1.0-linux.tgz

我已将文件提取到〜/"目录中

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

当我尝试以下python代码时:

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())

我遇到以下错误

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

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

推荐答案

您非常接近解决方案.将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.

这篇关于有谁知道如何在nltk上配置hunpos包装器类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆