def getInform(self, belief): ''' ''' act = "null()" done = False global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) inform_summary = [] for num_accepted in range(1, MAX_NUM_ACCEPTED + 1): inform_summary.append( SummaryMapping.actionSpecificInformSummary( belief, num_accepted, self.domainUtil)) count80 = global_summary['GLOBAL_COUNT80'] offer_happened = global_summary['GLOBAL_OFFERHAPPENED'] if count80 >= MAX_NUM_ACCEPTED: count80 = MAX_NUM_ACCEPTED - 1 arr = inform_summary[count80] first = arr[0] # True if there is no matching entities second = arr[1] # True if there is one matching entities #third = arr[2] # True if there is two~four matching entities discr = arr[4] # True if we can discriminate more requested_slots = DMUtils.getRequestedSlots(belief) #if (first or second or not discr or count80 >= len(Settings.ontology['system_requestable'])) and len(requested_slots)==0: act = DMUtils.getInformAction(count80, belief, self.domainUtil) if act != "null()": done = True return [done, act]
def getInform(self, belief): """ """ act = "null()" done = False global_summary = SummaryMapping.globalSummary(belief, self.domainUtil) inform_summary = [] for num_accepted in range(1, MAX_NUM_ACCEPTED + 1): inform_summary.append(SummaryMapping.actionSpecificInformSummary(belief, num_accepted, self.domainUtil)) count80 = global_summary["GLOBAL_COUNT80"] offer_happened = global_summary["GLOBAL_OFFERHAPPENED"] if count80 >= MAX_NUM_ACCEPTED: count80 = MAX_NUM_ACCEPTED - 1 arr = inform_summary[count80] first = arr[0] # True if there is no matching entities second = arr[1] # True if there is one matching entities # third = arr[2] # True if there is two~four matching entities discr = arr[4] # True if we can discriminate more requested_slots = DMUtils.getRequestedSlots(belief) # if (first or second or not discr or count80 >= len(Settings.ontology['system_requestable'])) and len(requested_slots)==0: act = DMUtils.getInformAction(count80, belief, self.domainUtil) if act != "null()": done = True return [done, act]
def _getInform(self, belief, global_summary, inform_summary): act = 'null()' count80 = global_summary['GLOBAL_COUNT80'] offer_happened = global_summary['GLOBAL_OFFERHAPPENED'] if count80 >= MAX_NUM_ACCEPTED: count80 = MAX_NUM_ACCEPTED - 1 arr = inform_summary[count80] first = arr[0] # True if there is no matching entities second = arr[1] # True if there is one matching entities #third = arr[2] # True if there is two~four matching entities discr = arr[4] # True if we can discriminate more logger.debug( '%d among %d slots are accepted (>=0.8 belief).' % (count80, len(self.domainUtil.sorted_system_requestable_slots))) #logger.debug('%d among %d slots are accepted (>=0.8 belief).' % (count80, len(Settings.ontology['system_requestable']))) if first or second or not discr or count80 >= len( self.domainUtil.ontology['system_requestable']): # If this inform gives either 0 or 1 or we've found everything we can ask about logger.debug( 'Trying to get inform action, have enough accepted slots.') logger.debug('Is there no matching entity? %s.' % str(first)) logger.debug('Is there only one matching entity? %s.' % str(second)) logger.debug('Can we discriminate more? %s.' % str(discr)) requested_slots = DMUtils.getRequestedSlots(belief) if len(requested_slots) > 0 and offer_happened: logger.debug('Getting inform requested action.') act = DMUtils.getGlobalAction(belief, 'INFORM_REQUESTED', domainUtil=self.domainUtil) else: logger.debug( 'Getting inform exact action with %d accepted slots.' % count80) act = DMUtils.getInformAction(count80, belief, domainUtil=self.domainUtil) if act != 'null()': return True, act return False, act
def _getInform(self, belief, global_summary, inform_summary): act = 'null()' count80 = global_summary['GLOBAL_COUNT80'] offer_happened = global_summary['GLOBAL_OFFERHAPPENED'] if count80 >= MAX_NUM_ACCEPTED: count80 = MAX_NUM_ACCEPTED - 1 arr = inform_summary[count80] first = arr[0] # True if there is no matching entities second = arr[1] # True if there is one matching entities #third = arr[2] # True if there is two~four matching entities discr = arr[4] # True if we can discriminate more logger.debug('%d among %d slots are accepted (>=0.8 belief).' % (count80, len(self.domainUtil.sorted_system_requestable_slots))) #logger.debug('%d among %d slots are accepted (>=0.8 belief).' % (count80, len(Settings.ontology['system_requestable']))) if first or second or not discr or count80 >= len(self.domainUtil.ontology['system_requestable']): # If this inform gives either 0 or 1 or we've found everything we can ask about logger.debug('Trying to get inform action, have enough accepted slots.') logger.debug('Is there no matching entity? %s.' % str(first)) logger.debug('Is there only one matching entity? %s.' % str(second)) logger.debug('Can we discriminate more? %s.' % str(discr)) requested_slots = DMUtils.getRequestedSlots(belief) if len(requested_slots) > 0 and offer_happened: logger.debug('Getting inform requested action.') act = DMUtils.getGlobalAction(belief, 'INFORM_REQUESTED', domainUtil=self.domainUtil) else: logger.debug('Getting inform exact action with %d accepted slots.' % count80) act = DMUtils.getInformAction(count80, belief, domainUtil=self.domainUtil) if act != 'null()': return True, act return False, act