In [1]:
# Conditional Frequency Distribution
# on nltk for a given list of tuples gives the
import nltk
In [2]:
names = [('Group A', 'Hari'), ('Group A', 'Bhavu'), ('Group A', 'Siri'),
('Group B', 'Ajith'), ('Group B', 'Kittu'), ('Group B', 'Kittu'), ('Group B', 'Laks')]
In [3]:
# When we run .FreqDist(), the distribution listed with by tuples
nltk.FreqDist(names)
Out[3]:
In [4]:
# When we used .ConditionalFreqDist() it grouped by first string with FreqDist as key with second string of tuple
# and value as the counter of it
nltk.ConditionalFreqDist(names)
Out[4]:
In [ ]: