def __init__(self, domain: JSONLookupDomain, parameters=None): self.domain = domain self.parameters = parameters or {} # cache inform and request slots # make sure to copy the list (shallow is sufficient) self.inf_slots = sorted(list(domain.get_informable_slots())[:]) # make sure that primary key is never a constraint if self.domain.get_primary_key() in self.inf_slots: self.inf_slots.remove(self.domain.get_primary_key()) # TODO sometimes ask for specific primary key with very small probability (instead of any other constraints?) # pylint: disable=line-too-long self.inf_slot_values = {} for slot in self.inf_slots: self.inf_slot_values[slot] = sorted( domain.get_possible_values(slot)[:]) self.req_slots = sorted(domain.get_requestable_slots()[:]) # self.req_slots_without_informables = sorted(list( # set(self.req_slots).difference(self.inf_slots))) # make sure that primary key is never a request as it is added anyway if self.domain.get_primary_key() in self.req_slots: self.req_slots.remove(self.domain.get_primary_key()) self.constraints = [] self.requests = {} self.excluded_inf_slot_values = {} self.missing_informs = []
def _create_inform_json(domain: JSONLookupDomain, template: RegexFile): inform_regex_json = {} for slot in domain.get_informable_slots(): inform_regex_json[slot] = {} for value in domain.get_possible_values(slot): inform_act = UserAct(act_type=UserActionType.Inform, slot=slot, value=value) inform_regex_json[slot][value] = template.create_regex(inform_act) return inform_regex_json
def __init__(self, domain: JSONLookupDomain, parameters=None): """ The class representing a goal, therefore containing requests and constraints. Args: domain (JSONLookupDomain): The domain for which the goal will be instantiated. It will only work within this domain. parameters (dict): The parameters for the goal defined by a key=value mapping: 'MinVenues' (int) allows to set a minimum number of venues which fulfill the constraints of the goal, 'MinConstraints' (int) and 'MaxConstraints' (int) set the minimum and maximum amount of constraints respectively, 'MinRequests' (int) and 'MaxRequests' (int) set the minimum and maximum amount of requests respectively and 'Reachable' (float) allows to specify how many (in percent) of all generated goals are definitely fulfillable (i.e. there exists a venue for the current goal) or not (doesn't have to be fulfillable). Although the parameter 'Reachable' equals 1.0 implicitly states that 'MinVenues' equals 1 or more, the implementation looks different, is more efficient and takes all goals into consideration (since 'Reachable' is a float (percentage of generated goals)). On the other hand, setting 'MinVenues' to any number bigger than 0 forces every goal to be fulfillable. """ self.domain = domain self.parameters = parameters or {} # cache inform and request slots # make sure to copy the list (shallow is sufficient) self.inf_slots = sorted(list(domain.get_informable_slots())[:]) # make sure that primary key is never a constraint if self.domain.get_primary_key() in self.inf_slots: self.inf_slots.remove(self.domain.get_primary_key()) # TODO sometimes ask for specific primary key with very small probability (instead of any other constraints?) # pylint: disable=line-too-long self.inf_slot_values = {} for slot in self.inf_slots: self.inf_slot_values[slot] = sorted( domain.get_possible_values(slot)[:]) self.req_slots = sorted(domain.get_requestable_slots()[:]) # self.req_slots_without_informables = sorted(list( # set(self.req_slots).difference(self.inf_slots))) # make sure that primary key is never a request as it is added anyway if self.domain.get_primary_key() in self.req_slots: self.req_slots.remove(self.domain.get_primary_key()) self.constraints = [] self.requests = {} self.excluded_inf_slot_values = {} self.missing_informs = []