I have some code that works well computing term frequency on a chosen list using the counter class import.
from collections import Counter
terms=['the', 'fox', 'the', 'quick', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']
tf = Counter(terms)
print(tf)
The existing code works great but I am wondering what would be the leanest way to achieve the same result strictly using a bag/multiset ADT without the help of the python counter class.
I have spent several days experimenting with code and looking on other forums without much success.