简体   繁体   中英

ImportError: cannot import name 'deprecated' from 'gensim.utils

while importing the below lines Jupyter compiler result in an error.

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

Error as follows:

~\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)

The summarization code was removed from Gensim 4.0. See:

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.

If you need it, you could try:

  • installing the older gensim version; 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's only extractive summarization - choosing a few key sentences from those that already exist – which only gives impressive results when the source text was already well-written in an expository style mixing high-level summaries with details. And its method of analyzing/ranking words is very crude & hard-to-customize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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