#NEWLINE# def get_log_click_probs( self , session ) : #NEWLINE# #INDENT# '\n            Returns an average log-likelihood for a given session,\n            i.e. log-likelihood of all the click events, divided\n            by the number of documents in the session.\n        ' #NEWLINE# possibleIntents = ( [ False ] if session . ignoreIntents else [ False , True ] ) #NEWLINE# intentWeight = ( { #NEWLINE# #INDENT# False : 1.0 , #NEWLINE# #UNINDENT# } if self . ignoreIntents else { #NEWLINE# #INDENT# False : ( 1 - session . intentWeight ) , #NEWLINE# True : session . intentWeight , #NEWLINE# #UNINDENT# } ) #NEWLINE# clickProbs = self . _get_click_probs ( s , possibleIntents ) #NEWLINE# N = min ( len ( session . clicks ) , self . config . get ( 'MAX_DOCS_PER_QUERY' , MAX_DOCS_PER_QUERY ) ) #NEWLINE# return ( math . log ( sum ( ( ( clickProbs [ i ] [ ( N - 1 ) ] * intentWeight [ i ] ) for i in possibleIntents ) ) ) / N )