def apply_features(feature_func, toks, labeled=None):
 if (labeled is None):
  labeled = (toks and isinstance(toks[0], (tuple, list)))
 if labeled:
  def lazy_func(labeled_token):
   return (feature_func(labeled_token[0]), labeled_token[1])
  return LazyMap(lazy_func, toks)
 else:
  return LazyMap(feature_func, toks)

def apply_features ( feature_func , toks , labeled = None ) : if ( labeled is None ) : labeled = ( toks and isinstance ( toks [ 0 ] , ( tuple , list ) ) ) if labeled : def lazy_func ( labeled_token ) : return ( feature_func ( labeled_token [ 0 ] ) , labeled_token [ 1 ] ) return LazyMap ( lazy_func , toks ) else : return LazyMap ( feature_func , toks )
use the lazymap class to construct a lazy list-like object that is analogous to map .