Most common words in file
Hello,
I'm back !
Today i face a very simple task i need to read a file then get ten most common words in text and print them you can use the same idea for e.g at facebook timeline application print most common words in your timeline todo summarize for facebook feeds.
Algorithm steps:
1- Import string module
2-Open file
3-create empty dictionary
4- read each line in file
5-remove any special character
6-convert all string into lower case
7- split every line into words
8-loop through words
9-count every word how many times appeared
10-create empty list
11-reverse desc
12- print top ten as key,value
I'm back !
Today i face a very simple task i need to read a file then get ten most common words in text and print them you can use the same idea for e.g at facebook timeline application print most common words in your timeline todo summarize for facebook feeds.
Algorithm steps:
1- Import string module
2-Open file
3-create empty dictionary
4- read each line in file
5-remove any special character
6-convert all string into lower case
7- split every line into words
8-loop through words
9-count every word how many times appeared
10-create empty list
11-reverse desc
12- print top ten as key,value
That's it :)
Comments
Post a Comment