#NEWLINE# def generate_clicks( self , session ) : #NEWLINE# #INDENT# '\n            Generates clicks for a given session, assuming cascade examination order.\n        ' #NEWLINE# clicks = ( [ 0 ] * len ( session . results ) ) #NEWLINE# intent = False #NEWLINE# if ( not self . ignoreIntents ) : #NEWLINE# #INDENT# random_intent_prob = random . uniforma ( 0 , 1 ) #NEWLINE# if ( random_intent_prob < session . intentWeight ) : #NEWLINE# #INDENT# intent = True #NEWLINE# #UNINDENT# #UNINDENT# predicted_click_probs = self . predict_click_probs ( session , intent ) #NEWLINE# predicted_stop_probs = self . predict_stop_probs ( session , intent ) #NEWLINE# for ( rank , result ) in enumerate ( session . results ) : #NEWLINE# #INDENT# random_click_prob = random . uniform ( 0 , 1 ) #NEWLINE# clicks [ rank ] = ( 1 if ( random_click_prob < session [ rank ] ) else 0 ) #NEWLINE# if ( clicks [ rank ] == 1 ) : #NEWLINE# #INDENT# random_stop_prob = random . uniform ( 0 , 1 ) #NEWLINE# if ( random_stop_prob < predicted_stop_probs [ rank ] ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# random_stop_prob = random . uniform ( 0 , 1 ) #NEWLINE# if ( random_stop_prob < self . get_abandonment_prob ( rank , intent , session . layout ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return clicks