gpt4 book ai didi

google-cloud-platform - Google colaboratory 中没有名为 'nltk.lm' 的模块

转载 作者:行者123 更新时间:2023-12-05 01:55:43 25 4
gpt4 key购买 nike

我试图在 Google 协作笔记本中导入 NLTK 语言建模模块 ( nltk.lm) 但没有成功。我试过从 nltk 安装所有东西,但仍然没有成功。

我可能犯了什么错误或遗漏?

提前致谢。

enter image description here . enter image description here

最佳答案

Google Colab 安装了 nltk v3.2.5,但 nltk.lm(语言建模包)was added in v3.4 .

在您的 Google Colab 运行中:

!pip install -U nltk

在输出中你会看到它下载了一个新版本,并卸载了旧版本:

...
Downloading nltk-3.6.5-py3-none-any.whl (1.5 MB)
...
Successfully uninstalled nltk-3.2.5
...
You must restart the runtime in order to use newly installed versions.

单击输出末尾显示的 Restart runtime 按钮。

现在它应该可以工作了!

您可以使用此代码仔细检查 nltk 版本:

import nltk
print('The nltk version is {}.'.format(nltk.__version__))

您需要 v3.4 或更高版本才能使用 nltk.lm

关于google-cloud-platform - Google colaboratory 中没有名为 'nltk.lm' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70115709/

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