Skip to content

Commit 0d7b0a2

Browse files
committed
frequency of words in python
1 parent 3eb4e8e commit 0d7b0a2

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)