NLTK 无法找到 gs 文件 [英] NLTK was unable to find the gs file

查看:17
本文介绍了NLTK 无法找到 gs 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用斯坦福自然语言工具包 NLTK.安装所需文件后,我开始执行演示代码:

我使用的是 IPython;为了调试问题,我使用命令 %xmode verbose 将回溯详细程度设置为 verbose,该命令打印每个堆栈帧的局部变量.(请参阅下面的完整回溯)文件名是:

file_names=['gs', 'gswin32c.exe', 'gswin64c.exe']

在 Google 上搜索 gswin32c.exe 告诉我它是 ghostscript.

/Users/jasonwirth/anaconda/lib/python3.4/site-packages/nltk/__init__.py in find_file_iter(filename='gs', env_vars=['PATH'], searchpath=(),file_names=['gs', 'gswin32c.exe', 'gswin64c.exe'], url=None,verbose=False)517(文件名,网址))518 div = '='*75-->519 raise LookupError('

%s
%s
%s' % (div, msg, div))520第521话查找错误:============================================================================NLTK 无法找到 gs 文件!使用软件特定的配置参数或设置 PATH 环境变量.============================================================================

I'm trying to use NLTK, the stanford natural language toolkit. After install the required files, I start to execute the demo code: http://www.nltk.org/index.html

>>> import nltk

>>> sentence = """At eight o'clock on Thursday morning
... Arthur didn't feel very good."""

>>> tokens = nltk.word_tokenize(sentence)

>>> tokens

['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',

'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']

>>> tagged = nltk.pos_tag(tokens)

>>> tagged[0:6]

[('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),

('Thursday', 'NNP'), ('morning', 'NN')]

>>> entities = nltk.chunk.ne_chunk(tagged)

>>> entities

Then I get message:

LookupError: 

===========================================================================
NLTK was unable to find the gs file!
Use software specific configuration paramaters or set the PATH environment variable.

I tried google, but there's no one tell what the missing gs file is.

解决方案

I came across this error too.

gs stands for ghostscript. You get the error because your chunker is trying to use ghostscript to draw a parse tree of the sentence, something like this:

I was using IPython; to debug the issue I set the traceback verbosity to verbose with the command %xmode verbose, which prints the local variables of each stack frame. (see the full traceback below) The file names are:

file_names=['gs', 'gswin32c.exe', 'gswin64c.exe']

A little Google search for gswin32c.exe told me it was ghostscript.

/Users/jasonwirth/anaconda/lib/python3.4/site-packages/nltk/__init__.py in find_file_iter(filename='gs', env_vars=['PATH'], searchpath=(), file_names=['gs', 'gswin32c.exe', 'gswin64c.exe'], url=None, verbose=False)
    517                         (filename, url))
    518         div = '='*75
--> 519         raise LookupError('

%s
%s
%s' % (div, msg, div))
    520 
    521 def find_file(filename, env_vars=(), searchpath=(),

LookupError: 

===========================================================================
NLTK was unable to find the gs file!
Use software specific configuration paramaters or set the PATH environment variable.
===========================================================================

这篇关于NLTK 无法找到 gs 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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