Exemple #1
0
 def _updateDBfeatures(self, belief, eType):
     features = []
     for numAccepted in range(1, 6):
         temp = SummaryUtils.actionSpecificInformSummary(
             belief, numAccepted, eType)
         features += temp
     return features
Exemple #2
0
    def work_entity_retrieval(self, belief, global_summary):
        '''
        '''
        array_slot_summary = SummaryUtils.arraySlotSummary(belief, self.domainString)
        logger.debug(str(global_summary))
        logger.debug('HDC policy: getGlobal') 
        done, output = self._getGlobal(belief, global_summary)
        
        if not done:
            logger.debug('HDC policy: getConfirmSelect')
            done, output = self._getConfirmSelect(belief, array_slot_summary)
        if not done:
            logger.debug('HDC policy: getInform')
            inform_summary = []
            for num_accepted in range(1, MAX_NUM_ACCEPTED+1):
                temp = SummaryUtils.actionSpecificInformSummary(belief, num_accepted, self.domainString)
                inform_summary.append(temp)
                       
            done, output = self._getInform(belief, global_summary, inform_summary)
        if not done:
            logger.debug('HDC policy: getRequest')
            done, output = self._getRequest(belief, array_slot_summary)
        if not done:
            logger.warning("HDCPolicy couldn't find action: execute reqmore().")
            output = 'reqmore()'

        if output == 'badact()' or output == 'null()':
            logger.warning('HDCPolicy chose bad or null action')
            output = 'null()'

        if self.use_confreq:
            #TODO - known problem here if use_confreq is True (ie being used)  FIXME
            output = PolicyUtils.add_venue_count(output, belief)
        return output
Exemple #3
0
    def _updateMactFeat(self, last_feature, lastact):
        '''
        Add features into self.prevstate  - recording actions taken by machine

        :param last_feature: last system state features
        :type last_feature: dict
        
        :param lastact: last system dialgoue act
        :type lastact: string

        :return: None
        '''
        features = {}
        if self.turn == 0:
            features['lastInformedVenue'] = ''
            features['informedVenueSinceNone'] = []
            features['lastActionInformNone'] = False
            features['offerHappened'] = False

        else:
            last_system_act = dact.ParseAct(lastact, user=False)

            # lastInformedVenue
            current_informed_venue = BeliefTrackingUtils._getCurrentInformedVenue(last_system_act)
            current_informed_venue = self._list2str_bugfix(current_informed_venue)
            
            if current_informed_venue != '':
                features['lastInformedVenue'] = current_informed_venue
            elif last_feature != None and last_feature['lastInformedVenue'] != None:
                features['lastInformedVenue'] = last_feature['lastInformedVenue']

            # informedVenueSinceNone
            if last_feature['informedVenueSinceNone'] == None or \
		last_system_act == None or BeliefTrackingUtils._hasType(last_system_act, 'canthelp'):
                informedVenueSinceNone = []
            else:
                informedVenueSinceNone = last_feature['informedVenueSinceNone']
            if BeliefTrackingUtils._hasTypeSlot(last_system_act, 'offer', 'name'):
                venue = BeliefTrackingUtils._getTypeSlot(last_system_act, 'offer', 'name')
                venue = self._list2str_bugfix(venue)
                informedVenueSinceNone.append(venue)
            features['informedVenueSinceNone'] = informedVenueSinceNone

            # lastActionInformNone
            if BeliefTrackingUtils._hasType(last_system_act, 'canthelp'):
                features['lastActionInformNone'] = True
            else:
                features['lastActionInformNone'] = False

            # offerhappened
            if BeliefTrackingUtils._hasTypeSlot(last_system_act, 'offer', 'name'):
                features['offerHappened'] = True
            else:
                features['offerHappened'] = False

        # inform_info
        features['inform_info'] = []
        for numAccepted in range(1,6):
            temp =  SummaryUtils.actionSpecificInformSummary(self.prevbelief, numAccepted, self.domainString)
            features['inform_info'] += temp
           
        self.prevbelief['features'] = features