code for frequancy python code example
Example 1: freq count in python
freq = {}
for item in my_list:
if (item in freq):
freq[item] += 1
else:
freq[item] = 1
Example 2: calculate term frequency python
from collections import Counter
# Counter token frequency from a sentence
sentence = "Texas A&M University is located in Texas"
term_frequencies = Counter(sentence.split())