Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unidecode
- import string
- import re
- from collections import Counter
- def word_counter(text):
- standardize = unidecode.unidecode(text.lower())
- punctuations = '[{}]'.format(re.escape(string.punctuation))
- removing_punctuations = re.sub(punctuations, " ", standardize).split()
- counting_words = Counter(removing_punctuations).most_common()
- for word, count in counting_words:
- print("{} = {}".format(word, count))
- if __name__ == "__main__":
- word_counter('''text here''')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement