def calculate_nfmap(train_toks, encoding):
 nfset = set()
 for (tok, _) in train_toks:
  for label in encoding.labels():
   nfset.add(sum((val for (id, val) in encoding.encode(tok, label))))
 return dict(((nf, i) for (i, nf) in enumerate(nfset)))

def calculate_nfmap ( train_toks , encoding ) : nfset = set ( ) for ( tok , _ ) in train_toks : for label in encoding . labels ( ) : nfset . add ( sum ( ( val for ( id , val ) in encoding . encode ( tok , label ) ) ) ) return dict ( ( ( nf , i ) for ( i , nf ) in enumerate ( nfset ) ) )
construct a map that can be used to compress nf .