def isbow(vec):
 if scipy.sparse.issparse(vec):
  vec = vec.todense().tolist()
 try:
  (id_, val_) = vec[0]
  (id_, val_) = (int(id_), float(val_))
 except IndexError:
  return True
 except Exception:
  return False
 return True

def isbow ( vec ) : if scipy . sparse . issparse ( vec ) : vec = vec . todense ( ) . tolist ( ) try : ( id_ , val_ ) = vec [ 0 ] ( id_ , val_ ) = ( int ( id_ ) , float ( val_ ) ) except IndexError : return True except Exception : return False return True
checks if vector passed is in bag of words representation or not .