Search code examples
pythondjangonlpgensim

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


I have included the 2 import statements in my views.py

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

However, even after I installed gensim using pip, I am getting the error:

ModuleNotFoundError: No module named 'gensim.summarization'

Solution

  • 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 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.