Esempio n. 1
0
def create_json_from_template(domain: JSONLookupDomain,
                              template_filename: str):
    template = RegexFile(template_filename, domain)
    domain_name = domain.get_domain_name()
    _write_dict_to_file(_create_request_json(domain, template),
                        f'{domain_name}RequestRules.json')
    _write_dict_to_file(_create_inform_json(domain, template),
                        f'{domain_name}InformRules.json')
Esempio n. 2
0
    def __init__(self,
                 domain: JSONLookupDomain = None,
                 subgraph=None,
                 logger: DiasysLogger = DiasysLogger()):
        super(MLBST, self).__init__(domain, subgraph, logger=logger)
        self.path_to_data_folder = os.path.join(os.path.realpath(os.curdir),
                                                "modules", "bst", "ml")
        self.primary_key = domain.get_domain_name()

        self.data_mappings = DSTC2Data(
            path_to_data_folder=self.path_to_data_folder,
            preprocess=False,
            load_train_data=False)

        self.inf_trackers = {}
        self.req_trackers = {}

        for inf_slot in domain.get_informable_slots():
            self._load_inf_model(inf_slot)
        for req_slot in domain.get_requestable_slots():
            self._load_req_model(req_slot)
Esempio n. 3
0
    def __init__(self, domain: JSONLookupDomain, logger: DiasysLogger = DiasysLogger(),
                 language: Language = None):
        """
        Loads
            - domain key
            - informable slots
            - requestable slots
            - domain-independent regular expressions
            - domain-specific regualer espressions

        It sets the previous system act to None

        Args:
            domain {domain.jsonlookupdomain.JSONLookupDomain} -- Domain
        """
        Service.__init__(self, domain=domain)
        self.logger = logger

        self.language = language if language else Language.ENGLISH

        # Getting domain information
        self.domain_name = domain.get_domain_name()
        self.domain_key = domain.get_primary_key()

        # Getting lists of informable and requestable slots
        self.USER_INFORMABLE = domain.get_informable_slots()
        self.USER_REQUESTABLE = domain.get_requestable_slots()

        # Getting the relative path where regexes are stored
        self.base_folder = os.path.join(get_root_dir(), 'resources', 'nlu_regexes')

        # Setting previous system act to None to signal the first turn
        # self.prev_sys_act = None
        self.sys_act_info = {
            'last_act': None, 'lastInformedPrimKeyVal': None, 'lastRequestSlot': None}

        self.language = Language.ENGLISH
        self._initialize()
Esempio n. 4
0
    def __init__(self,
                 domain: JSONLookupDomain,
                 subgraph=None,
                 logger: DiasysLogger = DiasysLogger(),
                 language: Language = None):
        """
        Loads
            - domain key
            - informable slots
            - requestable slots
            - domain-independent regular expressions
            - domain-specific regualer espressions

        It sets the previous system act to None

        Args:
            domain {domain.jsonlookupdomain.JSONLookupDomain} -- Domain
            subgraph  {[type]} -- [see modules.Module] (default: {None})
            logger:
        """
        super(HandcraftedNLU, self).__init__(domain, None, logger=logger)

        self.language = language if language else Language.ENGLISH

        # Getting domain information
        self.domain_name = domain.get_domain_name()
        self.domain_key = domain.get_primary_key()

        # Getting lists of informable and requestable slots
        self.USER_INFORMABLE = domain.get_informable_slots()
        self.USER_REQUESTABLE = domain.get_requestable_slots()

        # Getting the relative path where regexes are stored
        self.base_folder = os.path.join(get_root_dir(), 'resources', 'regexes')

        # Setting previous system act to None to signal the first turn
        self.prev_sys_act = None