Esempio n. 1
0
 def _get_slot_values(self, slot):
     '''Get a all distinct values for the given slot.'''
     values = set()
     tables_fields = self._get_slot_mapping(slot)
     for tbf in tables_fields:#sample a value of each table which the slot is connected
         if iscallable(tbf):#slot have values generated dynamic from one or several funs
             values = values.union(tbf())
         else:
             tb, f = tbf
             values = values.union(self.db.get_field_values(tb, f))
     return list(values)
Esempio n. 2
0
 def _get_random_slot_value(self, slot):
     '''Get a random value for the given slot.'''
     values = []
     tables_fields = self._get_slot_mapping(slot)
     for tbf in tables_fields:#sample a value of each table which the slot is connected
         if iscallable(tbf):#slot have values generated dynamic from one or several funs
             v = sample_from_list(tbf(self.goal, slot))
             values.append(v)
         else:  
             tb, f = tbf
             row = self._get_random_row(tb)
             values.append(self.db.get_row_field_value(tb, row, f))
     return sample_from_list(values)#take one in the sampled values