Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find most repeated word in a string in python

from collections import Counter

# Example phrase 
phrase = "John is the son of John second. Second son of John second is William second."
split_phrase = phrase.split()

# create counter object
Counter = Counter(split_phrase)

most_occured_words = Counter.most_common(4)
  
print(most_occured_words)
 
PREVIOUS NEXT
Tagged: #find #repeated #word #string #python
ADD COMMENT
Topic
Name
8+8 =