Skip to content
Advertisement

Counting word frequency and making a dictionary from it

I want to take every word from a text file, and count the word frequency in a dictionary.

Example: 'this is the textfile, and it is used to take words and count'

JavaScript

I am not that far, but I just can’t see how to complete it. My code so far:

JavaScript

Advertisement

Answer

If you don’t want to use collections.Counter, you can write your own function:

JavaScript

for finer things, look at regular expressions.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement