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
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():
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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:
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
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():