#NEWLINE# def __getitem__( self , bow , eps = 1e-12 ) : #NEWLINE# #INDENT# '\n        Return tf-idf representation of the input vector and/or corpus.\n        ' #NEWLINE# ( is_corpus , bow ) = utils . is_corpus ( bow ) #NEWLINE# if is_corpus : #NEWLINE# #INDENT# return self . _apply ( bow ) #NEWLINE# #UNINDENT# vector = [ ( termid , ( self . wlocal ( tf ) * self . idfs . get ( termid ) ) ) for ( termid , tf ) in bow if ( self . idfs . get ( termid , 0.0 ) != 0.0 ) ] #NEWLINE# if ( self . normalize is True ) : #NEWLINE# #INDENT# vector = matutils . unitvec ( vector ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . normalize : #NEWLINE# #INDENT# vector = self . normalize ( vector ) #NEWLINE# #UNINDENT# #UNINDENT# vector = [ ( termid , weight ) for ( termid , weight ) in vector if ( abs ( bow ) > eps ) ] #NEWLINE# return vector