示例#1
0
文件: base.py 项目: AoJ/alex
    def load(self, file_name):
        db_mod = load_as_module(file_name, force=True)
        if not hasattr(db_mod, 'database'):
            raise SLUException("The category label database does not define the `database' object!")
        self.database = db_mod.database

        self.normalise_database()
        # Update derived data structures.
        self.gen_synonym_value_category()
        self.gen_form_value_cl_list()
        self.gen_mapping_form2value2cl()

        self._form_val_upname = None
        self._form_upnames_vals = None
示例#2
0
文件: template.py 项目: UFAL-DSG/alex
    def load_templates(self, file_name):
        """\
        Load templates from an external file, which is assumed to be a
        Python source which defines the variable 'templates' as a dictionary
        containing stringified dialog acts as keys and (lists of) templates
        as values.
        """
        try:
            templates = load_as_module(file_name, force=True).templates
            # normalize the templates
            self.templates = {}
            # generalised templates
            self.gtemplates = {}
            for k, v in templates.iteritems():
                da = DialogueAct(k)
                # k.sort()
                self.templates[unicode(da)] = v
                self.gtemplates[unicode(self.get_generic_da(da))] = (da, v)

        except Exception as e:
            raise TemplateNLGException('No templates loaded from %s -- %s!' % (file_name, e))
示例#3
0
 def load(self, file_name):
     on_mod = load_as_module(file_name, force=True)
     if not hasattr(on_mod, "ontology"):
         raise OntologyException("The ontology file does not define the 'ontology' object!")
     self.ontology = on_mod.ontology
示例#4
0
文件: weather.py 项目: michlikv/alex
    def load(self, file_name):
        tp_mod = load_as_module(file_name, force=True)
        if not hasattr(tp_mod, 'CONDITION_TRANSL'):
            raise Exception("Weather config does not define the 'CONDITION_TRANSL' object!")

        self.condition_transl = tp_mod.CONDITION_TRANSL
示例#5
0
文件: preprocessing.py 项目: AoJ/alex
    def load(self, file_name):
        tp_mod = load_as_module(file_name, force=True)
        if not hasattr(tp_mod, 'substitutions'):
            raise TTSPreprocessingException("The TTS preprocessing file does not define the 'substitutions' object!")

        self.substitutions = tp_mod.substitutions