def parse_megam_weights(s, features_count, explicit=True):
 if (numpy is None):
  raise ValueError('This function requires that numpy be installed')
 assert explicit, 'non-explicit not supported yet'
 lines = s.strip().split('\n')
 weights = numpy.zeros(features_count, 'd')
 for line in lines:
  if line.strip():
   (fid, weight) = line.split()
   weights[int(fid)] = float(weight)
 return weights

def parse_megam_weights ( s , features_count , explicit = True ) : if ( numpy is None ) : raise ValueError ( 'This function requires that numpy be installed' ) assert explicit , 'non-explicit not supported yet' lines = s . strip ( ) . split ( '\n' ) weights = numpy . zeros ( features_count , 'd' ) for line in lines : if line . strip ( ) : ( fid , weight ) = line . split ( ) weights [ int ( fid ) ] = float ( weight ) return weights
given the stdout output generated by megam when training a model .