Hi Haneul Kim, good observation. Let me elaborate in a cleaner way:
sentence[:15] selects the first 15 characters not words out of the sentence.
As an example, for “Those Who Are Resilient Stay In The Game Longer”, it will give “Those Who Are ”.
Now the question should be, Why?
We’ve used sentence[:15] as a key in Dictionary while creating the frequency matrix.
frequency_matrix[sent[:15]] = freq_table
Thus, again we’ve to use,
if sentence[:15] in sentenceValue
to get the value associated with the sentence. Here, the sentenceValue is a Dictionary and sentence[:15] is the key.
But while generating the summary, we’re adding the actual sentence as it is:
summary += " " + sentence
This will give us a summary with full sentences.
One more question, why sentece[:15] why not sentence[:10] or sentence[:20] ?
You can use anything, the reason we’re striping most of the part of the sentences is to save memory. Imagine, if we use long sentences as it is as a key of the Dictionary, it will eat up so much memory runtime.
The ideal way of dealing is to use Hash of the sentence as a key, which will be symmetrical for all the sentences.
I’ll try doing that soon, thanks for pointing out.
Best Regards, Akash