简体   繁体   English

无法从 Django 中的“gensim.summarization”模块导入

[英]Not able to import from `gensim.summarization` module in Django

I have included the 2 import statements in my views.py我在我的 views.py 中包含了 2 个导入语句

from gensim.summarization.summarizer import summarizer
from gensim.summarization import keywords

However, even after I installed gensim using pip, I am getting the error:但是,即使在我使用 pip 安装 gensim 之后,我仍然收到错误消息:

ModuleNotFoundError: No module named 'gensim.summarization'

The summarization code was removed from Gensim 4.0. summarization代码已从 Gensim 4.0 中删除。 See:看:

https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#12-removed-gensimsummarization https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#12-removed-gensimsummarization

12. Removed gensim.summarization 12.删除gensim.summarization

Despite its general-sounding name, the module will not satisfy the majority of use cases in production and is likely to waste people's time.尽管它的名字听起来很笼统,但该模块并不能满足生产中的大多数用例,而且很可能会浪费人们的时间。 See this Github ticket for more motivation behind this.请参阅这张 Github 票,了解更多背后的动机。

If you need it, you could try:如果你需要它,你可以尝试:

  • installing the older gensim version;安装较旧的 gensim 版本; or…要么…
  • copy the source code out to your own local module将源代码复制到您自己的本地模块

However, I expect you'd likely be disappointed by its inflexibility and how little it can do.但是,我预计您可能会对它的死板和无能为力感到失望。

It was only extractive summarization - choosing a few key sentences from those that already exist.只是提取性总结——从已经存在的句子中选择几个关键句子。 That only gives impressive results when the source text was already well-written in an expository style mixing high-level overview sentences with separate detail sentences.只有当源文本已经以混合高级概述句子和单独的细节句子的说明文风格很好地编写时,才会产生令人印象深刻的结果。 And, its method of analyzing/ranking words was very crude & hard-to-customize – totally unconnected to the more generic/configurable/swappable approaches used elsewhere in Gensim or in other text libraries.而且,它分析/排序单词的方法非常粗糙且难以定制——与 Gensim 或其他文本库中其他地方使用的更通用/可配置/可交换的方法完全无关。

You can run pip freeze within your environment to ensure it is installed here.您可以在您的环境中运行pip freeze以确保它已安装在此处。

If it is, then you should check naming of any modules or files you have in your directory to ensure there are no conflicts.如果是,那么您应该检查目录中所有模块或文件的命名,以确保没有冲突。

I had the same issue我遇到过同样的问题

As per Gensim's Github changelog 188, gensim.summarization module has been removed in versions Gensim 4.x as it was an unmaintained third-party module.根据 Gensim 的 Github 变更日志 188, gensim.summarization模块已在 Gensim 4.x 版本中删除,因为它是一个未维护的第三方模块。

To continue using gensim.summarization , you will need to downgrade the version of Gensim in the requirements.txt file by replacing it with gensim==3.8.3 or an older version.要继续使用gensim.summarization ,您需要将 requirements.txt 文件中的 Gensim 版本替换为gensim==3.8.3或更旧的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM