def _getGlobal(self, belief, global_summary):
        act = 'null()'

        if global_summary['GLOBAL_BYCONSTRAINTS'] > 0.5 and\
            global_summary['GLOBAL_COUNT80'] > 3:
            act = DMUtils.getGlobalAction(belief, 'INFORM_BYNAME', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_BYALTERNATIVES'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'INFORM_ALTERNATIVES', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_BYNAME'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'INFORM_REQUESTED', domainUtil=self.domainUtil )
        elif global_summary['GLOBAL_FINISHED'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'BYE', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_REPEAT'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'INFORM_REPEAT', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_REQMORE'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'INFORM_BYNAME', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_THANKYOU'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'REQMORE', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_ACK'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'REQMORE', domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_RESTART'] > 0.5:
            act = DMUtils.getGlobalAction(belief, 'RESTART', domainUtil=self.domainUtil)

        if act != 'null()':
            return True, act
        return False, act
 def getRestart(self, belief):
     """
     """
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = "null()"
     if global_summary["GLOBAL_RESTART"] > 0.5:
         act = DMUtils.getGlobalAction(belief, "RESTART", self.domainUtil)
     if act != "null()":
         done = True
     return done, act
 def getBye(self, belief):
     """
     """
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = "null()"
     if global_summary["GLOBAL_FINISHED"] > 0.5:
         act = DMUtils.getGlobalAction(belief, "BYE", self.domainUtil)
     if act != "null()":
         done = True
     return done, act
 def getReqMore(self, belief):
     """
     """
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = "null()"
     # if global_summary['GLOBAL_ACK'] > 0.5 or global_summary['GLOBAL_THANKYOU']>0.5:
     act = DMUtils.getGlobalAction(belief, "REQMORE", self.domainUtil)
     if act != "null()":
         done = True
     return done, act
 def getInformAlternatives(self, belief):
     """
     """
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = "null()"
     if global_summary["GLOBAL_BYALTERNATIVES"] > 0.5:
         act = DMUtils.getGlobalAction(belief, "INFORM_ALTERNATIVES", self.domainUtil)
     if act != "null()":
         done = True
     return done, act
 def getInformRequested(self, belief):
     """
     """
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = "null()"
     if global_summary["GLOBAL_BYNAME"] > 0.5:
         act = DMUtils.getGlobalAction(belief, "INFORM_REQUESTED", self.domainUtil)
     if act != "null()":
         done = True
     return done, act
 def getRestart(self, belief):
     '''
     '''
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = 'null()'
     if global_summary['GLOBAL_RESTART'] > 0.5:
         act = DMUtils.getGlobalAction(belief, 'RESTART', self.domainUtil)
     if act != 'null()':
         done = True
     return done, act
 def getBye(self, belief):
     '''
     '''
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = 'null()'
     if global_summary['GLOBAL_FINISHED'] > 0.5:
         act = DMUtils.getGlobalAction(belief, 'BYE', self.domainUtil)
     if act != 'null()':
         done = True
     return done, act
 def getReqMore(self, belief):
     '''
     '''
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = 'null()'
     #if global_summary['GLOBAL_ACK'] > 0.5 or global_summary['GLOBAL_THANKYOU']>0.5:
     act = DMUtils.getGlobalAction(belief, 'REQMORE', self.domainUtil)
     if act != 'null()':
         done = True
     return done, act
 def getInformRequested(self, belief):
     '''
     '''
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = 'null()'
     if global_summary['GLOBAL_BYNAME'] > 0.5:
         act = DMUtils.getGlobalAction(belief, 'INFORM_REQUESTED',
                                       self.domainUtil)
     if act != 'null()':
         done = True
     return done, act
 def getInformAlternatives(self, belief):
     '''
     '''
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = 'null()'
     if global_summary['GLOBAL_BYALTERNATIVES'] > 0.5:
         act = DMUtils.getGlobalAction(belief, 'INFORM_ALTERNATIVES',
                                       self.domainUtil)
     if act != 'null()':
         done = True
     return done, act
    def _getGlobal(self, belief, global_summary):
        act = 'null()'

        if global_summary['GLOBAL_BYCONSTRAINTS'] > 0.5 and\
            global_summary['GLOBAL_COUNT80'] > 3:
            act = DMUtils.getGlobalAction(belief,
                                          'INFORM_BYNAME',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_BYALTERNATIVES'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'INFORM_ALTERNATIVES',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_BYNAME'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'INFORM_REQUESTED',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_FINISHED'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'BYE',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_REPEAT'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'INFORM_REPEAT',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_REQMORE'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'INFORM_BYNAME',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_THANKYOU'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'REQMORE',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_ACK'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'REQMORE',
                                          domainUtil=self.domainUtil)
        elif global_summary['GLOBAL_RESTART'] > 0.5:
            act = DMUtils.getGlobalAction(belief,
                                          'RESTART',
                                          domainUtil=self.domainUtil)

        if act != 'null()':
            return True, act
        return False, act
 def getInformByName(self, belief):
     """
     """
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = "null()"
     if (
         global_summary["GLOBAL_BYCONSTRAINTS"]
         > 0.5  # or global_summary['GLOBAL_BYNAME'] >0 or global_summary['GLOBAL_BYALTERNATIVES'] > 0.5
     ) and global_summary["GLOBAL_COUNT80"] > 3:
         act = DMUtils.getGlobalAction(belief, "INFORM_BYNAME", self.domainUtil)
     if act != "null()":
         done = True
     return done, act
 def getInformByName(self, belief):
     '''
     '''
     global_summary = SummaryMapping.globalSummary(belief, self.domainUtil)
     done = False
     act = 'null()'
     if (global_summary['GLOBAL_BYCONSTRAINTS'] > 0.5 #or global_summary['GLOBAL_BYNAME'] >0 or global_summary['GLOBAL_BYALTERNATIVES'] > 0.5
         ) and\
         global_summary['GLOBAL_COUNT80'] > 3:
         act = DMUtils.getGlobalAction(belief, 'INFORM_BYNAME',
                                       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