def extract_bigram_feats(document, bigrams):
 features = {}
 for bigr in bigrams:
  features['contains({0} - {1})'.format(bigr[0], bigr[1])] = (bigr in nltk.bigrams(document))
 return features

def extract_bigram_feats ( document , bigrams ) : features = { } for bigr in bigrams : features [ 'contains({0} - {1})' . format ( bigr [ 0 ] , bigr [ 1 ] ) ] = ( bigr in nltk . bigrams ( document ) ) return features
populate a dictionary of bigram features .