def _getRequest(self, belief, array_slot_summary): #slots = Settings.ontology['system_requestable'] # This is added for confreq. need_grounding = DMUtils.getTopBeliefs(belief, 0.8, domainUtil=self.domainUtil) for slot in self.domainUtil.sorted_system_requestable_slots: #slots: summary = array_slot_summary[slot] (_, topprob) = summary['TOPTWO'][0] (_, secprob) = summary['TOPTWO'][1] if topprob < 0.8: # Add implicit confirmation (for confreq.) grounding_slots = copy.deepcopy(need_grounding) if slot in grounding_slots: del grounding_slots[slot] grounding_result = [] for grounding_slot in grounding_slots: if len(grounding_result) < 3: (value, prob) = grounding_slots[grounding_slot] grounding_result.append('%s="%s"' % (grounding_slot, value)) if not grounding_result or not self.use_confreq: return True, 'request(%s)' % slot else: return True, 'confreq(' + ','.join(grounding_result) + ',%s)' % slot return False, 'null()'
def _getRequest(self, belief, array_slot_summary): #slots = Settings.ontology['system_requestable'] # This is added for confreq. need_grounding = DMUtils.getTopBeliefs(belief, 0.8, domainUtil=self.domainUtil) for slot in self.domainUtil.sorted_system_requestable_slots: #slots: summary = array_slot_summary[slot] (_, topprob) = summary['TOPTWO'][0] (_, secprob) = summary['TOPTWO'][1] if topprob < 0.8: # Add implicit confirmation (for confreq.) grounding_slots = copy.deepcopy(need_grounding) if slot in grounding_slots: del grounding_slots[slot] grounding_result = [] for grounding_slot in grounding_slots: if len(grounding_result) < 3: (value, prob) = grounding_slots[grounding_slot] grounding_result.append('%s="%s"' % (grounding_slot, value)) if not grounding_result or not self.use_confreq: return True, 'request(%s)' % slot else: return True, 'confreq(' + ','.join( grounding_result) + ',%s)' % slot return False, 'null()'
def actionSpecificInformSummary(belief, numAccepted, domainUtil): '''count: # of entities matching with numAccepted slots in acceptance list. :param belief: (dict) full belief state :param numAccepted: (int) :param informable_slots: (list) :returns: summary_array [count==0, count==1, 2<=count<=4, count>4, discriminatable] \ discriminatable: matching entities can be further discriminated ''' acceptanceList = DMUtils.getTopBeliefs(belief, domainUtil=domainUtil) count = _countEntitiesForAcceptanceListPart(acceptanceList, numAccepted, domainUtil) discriminatable = _acceptanceListCanBeDiscriminated(acceptanceList, numAccepted, domainUtil) summary_array = [count == 0, count == 1, 2 <= count <= 4, count > 4, discriminatable] return summary_array
def actionSpecificInformSummary(belief, numAccepted, domainUtil): """count: # of entities matching with numAccepted slots in acceptance list. :param belief: (dict) full belief state :param numAccepted: (int) :param informable_slots: (list) :returns: summary_array [count==0, count==1, 2<=count<=4, count>4, discriminatable] \ discriminatable: matching entities can be further discriminated """ acceptanceList = DMUtils.getTopBeliefs(belief, domainUtil=domainUtil) count = _countEntitiesForAcceptanceListPart(acceptanceList, numAccepted, domainUtil) discriminatable = _acceptanceListCanBeDiscriminated(acceptanceList, numAccepted, domainUtil) summary_array = [count == 0, count == 1, 2 <= count <= 4, count > 4, discriminatable] return summary_array
def globalSummary(belief, domainUtil): '''summary of global actions such as offer happened etc. :param belief: (dict) full belief state :returns: (dict) summary. dict keys are given by :meth:`global_summary_features` ''' topMethod, topMethodBelief = DMUtils.getTopBelief(belief['beliefs']['method']) topDiscourseAct, topDiscourseActBelief = DMUtils.getTopBelief(belief['beliefs']['discourseAct']) if topMethod == 'byconstraints': globalpoint = 'GLOBAL_BYCONSTRAINTS' elif topMethod == 'byalternatives': globalpoint = 'GLOBAL_BYALTERNATIVES' elif topMethod == 'byname': globalpoint = 'GLOBAL_BYNAME' elif topMethod == 'finished' and topMethodBelief > 0.5: globalpoint = 'GLOBAL_FINISHED' elif topMethod == 'restart' and topMethodBelief > 0.5: globalpoint = 'GLOBAL_RESTART' else: globalpoint = 'GLOBAL_BYCONSTRAINTS' if topDiscourseAct == 'repeat' and topDiscourseActBelief > 0.5: globalpoint = 'GLOBAL_REPEAT' elif topDiscourseAct == 'reqmore' and topDiscourseActBelief > 0.5: globalpoint = 'GLOBAL_REQMORE' elif topDiscourseAct == 'thankyou' and topDiscourseActBelief > 0.5: globalpoint = 'GLOBAL_THANKYOU' elif topDiscourseAct == 'ack' and topDiscourseActBelief > 0.5: globalpoint = 'GLOBAL_ACK' summaryArray = dict.fromkeys(global_summary_features, False) summaryArray[globalpoint] = True summaryArray['GLOBAL_COUNT80'] = len(DMUtils.getTopBeliefs(belief, domainUtil=domainUtil)) summaryArray['GLOBAL_NAMENONE'] = belief['features']['lastActionInformNone'] summaryArray['GLOBAL_OFFERHAPPENED'] = belief['features']['offerHappened'] return summaryArray
def globalSummary(belief, domainUtil): """summary of global actions such as offer happened etc. :param belief: (dict) full belief state :returns: (dict) summary. dict keys are given by :meth:`global_summary_features` """ topMethod, topMethodBelief = DMUtils.getTopBelief(belief["beliefs"]["method"]) topDiscourseAct, topDiscourseActBelief = DMUtils.getTopBelief(belief["beliefs"]["discourseAct"]) if topMethod == "byconstraints": globalpoint = "GLOBAL_BYCONSTRAINTS" elif topMethod == "byalternatives": globalpoint = "GLOBAL_BYALTERNATIVES" elif topMethod == "byname": globalpoint = "GLOBAL_BYNAME" elif topMethod == "finished" and topMethodBelief > 0.5: globalpoint = "GLOBAL_FINISHED" elif topMethod == "restart" and topMethodBelief > 0.5: globalpoint = "GLOBAL_RESTART" else: globalpoint = "GLOBAL_BYCONSTRAINTS" if topDiscourseAct == "repeat" and topDiscourseActBelief > 0.5: globalpoint = "GLOBAL_REPEAT" elif topDiscourseAct == "reqmore" and topDiscourseActBelief > 0.5: globalpoint = "GLOBAL_REQMORE" elif topDiscourseAct == "thankyou" and topDiscourseActBelief > 0.5: globalpoint = "GLOBAL_THANKYOU" elif topDiscourseAct == "ack" and topDiscourseActBelief > 0.5: globalpoint = "GLOBAL_ACK" summaryArray = dict.fromkeys(global_summary_features, False) summaryArray[globalpoint] = True summaryArray["GLOBAL_COUNT80"] = len(DMUtils.getTopBeliefs(belief, domainUtil=domainUtil)) summaryArray["GLOBAL_NAMENONE"] = belief["features"]["lastActionInformNone"] summaryArray["GLOBAL_OFFERHAPPENED"] = belief["features"]["offerHappened"] return summaryArray