#NEWLINE# def __getitem__( self , bow , iterations = 100 ) : #NEWLINE# #INDENT# ( is_corpus , corpus ) = utils . is_corpus ( bow ) #NEWLINE# if ( not is_corpus ) : #NEWLINE# #INDENT# bow = [ bow ] #NEWLINE# #UNINDENT# self . convert_input ( bow , infer = True ) #NEWLINE# cmd = ( self . mallet_path + ' infer-topics --input %s --inferencer %s --output-doc-topics %s --num-iterations %s' ) #NEWLINE# cmd = ( bow % ( ( self . fcorpusmallet ( ) + '.infer' ) , self . finferencer ( ) , ( self . fdoctopics ( ) + '.infer' ) , iterations ) ) #NEWLINE# logger . info ( ( "inferring topics with MALLET LDA '%s'" % cmd ) ) #NEWLINE# retval = call ( cmd , shell = True ) #NEWLINE# if ( retval != 0 ) : #NEWLINE# #INDENT# raise RuntimeError ( ( 'MALLET failed with error %s on return' % retval ) ) #NEWLINE# #UNINDENT# result = list ( read_doctopics ( ( self . fdoctopics ( ) + '.infer' ) ) ) #NEWLINE# return ( result if is_corpus else result [ 0 ] )