def is_corpus(obj):
 try:
  if ('Corpus' in obj.__class__.__name__):
   return (True, obj)
 except:
  pass
 try:
  if (hasattr(obj, 'next') or hasattr(obj, '__next__')):
   doc1 = next(obj)
   obj = itertools.chain([doc1], obj)
  else:
   doc1 = next(iter(obj))
  if (len(doc1) == 0):
   return (True, obj)
  (id1, val1) = next(iter(doc1))
  (id1, val1) = (int(id1), float(val1))
 except Exception:
  return (False, obj)
 return (True, obj)

def is_corpus ( obj ) : try : if ( 'Corpus' in obj . __class__ . __name__ ) : return ( True , obj ) except : pass try : if ( hasattr ( obj , 'next' ) or hasattr ( obj , '__next__' ) ) : doc1 = next ( obj ) obj = itertools . chain ( [ doc1 ] , obj ) else : doc1 = next ( iter ( obj ) ) if ( len ( doc1 ) == 0 ) : return ( True , obj ) ( id1 , val1 ) = next ( iter ( doc1 ) ) ( id1 , val1 ) = ( int ( id1 ) , float ( val1 ) ) except Exception : return ( False , obj ) return ( True , obj )
check whether obj is a corpus .