0

I am trying to summarise some text using Gensim in python and want exactly 3 sentences in my summary. There doesn't seem to be an option to do this so I have done the following workaround:

with open ('speeches//'+speech, "r") as myfile:
    speech=myfile.read()
    sentences = speech.count('.')
    x = gensim.summarization.summarize(speech, ratio=3.0/sentences)

However this code is only giving me two sentences. Furthermore, as I incrementally increase 3 to 5 still nothing happens.

Any help would be most appreciated.

Om Prakash
  • 2,675
  • 4
  • 29
  • 50
Daniel Wyatt
  • 185
  • 1
  • 1
  • 12

1 Answers1

0

You may not be able use 'ratio' for this. If you give ratio=0.3, and you have 10 sentences (assuming count of words in each sentence is same), your output will have 3 sentences, 6 for 20 and so on.

As per gensim doc ratio (float, optional) – Number between 0 and 1 that determines the proportion of the number of sentences of the original text to be chosen for the summary.

Instead you might want to try using word_count, summarize(speech, word_count=60)

This question is a bit old, in case you found a better solution, pls share.

itsprit
  • 31
  • 1