【发布时间】:2020-04-13 05:58:36
【问题描述】:
我在this thread 上关注了所有内容,但我无法在 Google App Engine 上使用 NLTK。
我非常需要 GAE 上的 NLTK,请帮助。我面临以下问题。
>>> 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)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
tagged = nltk.pos_tag(tokens)
File "C:\Python27\lib\site-packages\nltk\tag\__init__.py", line 99, in pos_tag
tagger = load(_POS_TAGGER)
File "C:\Python27\lib\site-packages\nltk\data.py", line 605, in load
resource_val = pickle.load(_open(resource_url))
File "C:\Python27\lib\site-packages\nltk\data.py", line 686, in _open
return find(path).open()
File "C:\Python27\lib\site-packages\nltk\data.py", line 467, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'taggers/maxent_treebank_pos_tagger/english.pickle' not
found. Please use the NLTK Downloader to obtain the resource:
>>> nltk.download()
Searched in:
- 'C:\\Users\\Anshu/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Python27\\nltk_data'
- 'C:\\Python27\\lib\\nltk_data'
- 'C:\\Users\\Anshu\\AppData\\Roaming\\nltk_data'
**********************************************************************
>>>
【问题讨论】:
-
@AshishNitinPatil 不,不要认为它与那些重复。这是 GAE 特有的。但是,它可能与 link 重复。
-
你有一堆问题,nltk lib必须安装在appengine项目目录中,这样才能与代码一起部署。因此,您所做的任何事情 - 即您上面的外壳示例都与 appengine 安装无关。其次,nltk 需要的任何其他资源也需要在您的 appengine 项目中手动安装。
标签: python google-app-engine python-2.7 nltk