DEV Community


Discussion on: Build a quick Summarizer with Python and NLTK

davidisrawi profile image
David Israwi Author

It seems like your bug comes from separating the paragraphs into letters instead of words.

The program should do the following commands in the respective order:

  • Separate the body of text into sentences using sentence tokenizer
  • Separate sentences into words using the word tokenizer
  • Find frequency of each word while building bag of words

I wouldn't be able to know in which step the bug is, but it seems as if you are finding the frequency of each letter instead of each word, make sure you are keeping track of your arrays by printing them through your code, seems like you're almost there

mishail98 profile image

I too am confused about this. According to my understanding, when we use the in operator in a dictionary, it only iterates through the keys. Therefore it would make sense that the program is printing only the first letter.

I guess to get the key-value pairs, we need to use the items() function as:
for wordValue in freqTable.items():

Forem Open with the Forem app