I\'d like to count frequencies of all words in a text file.
>>> countInFile(\'test.txt\')
should return {\'aaa\':1, \'bbb\':
you can try with sklearn
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
data=['i am student','the student suffers a lot']
transformed_data =vectorizer.fit_transform(data)
vocab= {a: b for a, b in zip(vectorizer.get_feature_names(), np.ravel(transformed_data.sum(axis=0)))}
print (vocab)