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

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.

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

--

--

SDE 2 @Amazon. Here to share the knowledge and experiences. https://akashpanchal.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store