Skip to content

Commit 4d9cef1

Browse files
Merge pull request #316 from rudraneel18/main
frequency of words in python
2 parents 6f8e99d + 0d7b0a2 commit 4d9cef1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Python/frequency_of_words.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from collections import Counter
2+
line_text = "As a part of text analytics, we frequently need to count words and assign weightage to them for processing in various algorithms, so in this article we will see how we can find the frequency of each word in a given sentence. We can do it with three approaches as shown below."
3+
freq = Counter(line_text.split()).most_common()
4+
[print(word, count) for word, count in freq]

0 commit comments

Comments
 (0)