In NLP the most recurrent task is to find the frequency of words in a text file or a huge corpora. Below is one such script that we can use to find frequency of words in a text file. This script uses python dictionary. To know more about dictionary usage in Python click here.
This script opens the file ‘raw_corpus.txt’, each lines is split into words. Each word is stored in dictionary, with key as word and value as the frequency. When the same word(key) is encountered again value is incremented by 1.