ImportError:无法从“gensim.utils”导入名称“已弃用”

2024-04-30 05:03:29 发布

您现在位置:Python中文网/ 问答频道 /正文

导入以下行时,Jupyter编译器将导致错误

ImportError: cannot import name 'deprecated' from 'gensim.utils
from gensim.summarization.summarizer import summarize
from gensim.summarization import keywords**

错误如下:

~\AppData\Local\Programs\Python\Python39\Lib\site-packages\gensim\summarization\summarizer.py in <module>
     54 
     55 import logging
---> 56 from gensim.utils import deprecated
     57 from gensim.summarization.pagerank_weighted import pagerank_weighted as _pagerank
     58 from gensim.summarization.textcleaner import clean_text_by_sentences as _clean_text_by_sentences

ImportError: cannot import name 'deprecated' from 'gensim.utils' (C:\Users\PavanKumar\AppData\Local\Programs\Python\Python39\Lib\site-packages\gensim\utils.py)

Tags: namefromimportlocal错误utilsappdatadeprecated
1条回答
网友
1楼 · 发布于 2024-04-30 05:03:29

已从Gensim 4.0中删除summarization代码。见:

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

12. Removed 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.

如果需要,您可以尝试:

  • 安装较旧的gensim版本;或者
  • 将源代码复制到您自己的本地模块

然而,我想你可能会对它的僵化和它所能做的很少感到失望。它是摘录摘要-从已经存在的句子中选择一些关键句子-只有当源文本已经以解释性风格写得很好时,才能给出令人印象深刻的结果,将高级摘要与细节混合在一起。它对单词的分析/排序方法非常粗糙;很难定制

相关问题 更多 >