예제 #1
0
 def clean(self, s):
     s = s.replace('<go> ', '').replace(' SLOT', '_SLOT')
     s = '<GO> ' + s + ' </s>'
     for item in self.entity_dict:
         # s = s.replace(item, 'VALUE_{}'.format(self.entity_dict[item]))
         s = clean_replace(s, item,
                           '{}_SLOT'.format(self.entity_dict[item]))
     return s
예제 #2
0
    def clean_by_intent(self, s, i):
        s = s.replace('<go> ', '').replace(' SLOT', '_SLOT')
        s = '<GO> ' + s + ' </s>'
        intent = self.raw_data[i]['scenario']['task']['intent']
        slot = {
            'weather': ['weather_attribute', 'location', 'weekly_time'],
            'navigate': ['poi', 'poi_type', 'distance', 'traffic', 'address'],
            'schedule': ['event', 'date', 'time', 'party', 'room', 'agenda']
        }

        for item in self.entity_dict:
            if self.entity_dict[item] in slot[intent]:
                # s = s.replace(item, 'VALUE_{}'.format(self.entity_dict[item]))
                s = clean_replace(s, item,
                                  '{}_SLOT'.format(self.entity_dict[item]))
        return s