The script accepts a way to the text file on an input and to print in the console ten most popular words in this file in decreasing order of frequency.
Example use as module:
import lang_frequency
file_text = load_data(r'd:\PythonScript\Devman\RomeoAndJuliet.txt')
get_most_frequent_words(file_text, 10)
# Output example
[('the', 865), ('and', 787), ('to', 622), ('i', 582), ('of', 533), ('a', 524), ('in', 375), ('is', 372), ('my', 360), ('that', 358)]
The code is written for educational purposes. Training course for web-developers - DEVMAN.org