gpt4 book ai didi

python - NLTK 无法找到 gs 文件

转载 作者:太空狗 更新时间:2023-10-29 17:17:12 26 4
gpt4 key购买 nike

我正在尝试使用斯坦福自然语言工具包 NLTK。安装所需文件后,我开始执行演示代码: 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',

“亚瑟”、“做过”、“没”、“感觉”、“非常”、“好”、“。”]

>>> tagged = nltk.pos_tag(tokens)

>>> tagged[0:6]

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

('星期四', 'NNP'), ('早上', 'NN')]

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

>>> entities

然后我收到消息:

LookupError: 

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

我试过谷歌,但没有人知道丢失的 gs 文件是什么。

最佳答案

我也遇到过这个错误。

gs 代表 ghostscript。你得到这个错误是因为你的分 block 器试图使用 ghostscript 来绘制句子的解析树,就像这样:

enter image description here

我使用的是 IPython;为了调试问题,我使用命令 %xmode verbose 将 traceback verbosity 设置为 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 (filename, url))
518 div = '='*75
--> 519 raise LookupError('\n\n%s\n%s\n%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.
===========================================================================

关于python - NLTK 无法找到 gs 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36942270/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com