Beispiel #1
0
    def setUp(self):

        config = misc.load_config('.airc')

        #
        # logic DB
        #

        self.db = LogicDB(model.url)

        #
        # knowledge base
        #

        self.kb = AIKB(UNITTEST_MODULE)

        for prefix in COMMON_PREFIXES:
            self.kb.register_prefix(prefix, COMMON_PREFIXES[prefix])

        self.kb.clear_all_graphs()

        self.kb.parse_file (UNITTEST_CONTEXT, 'n3', 'tests/chancellors.n3')
        self.kb.parse_file (UNITTEST_CONTEXT, 'n3', 'tests/wev.n3')

        #
        # aiprolog environment setup
        #

        self.prolog_rt = AIPrologRuntime(self.db, self.kb)
        self.parser    = AIPrologParser()

        self.prolog_rt.set_trace(True)

        self.db.clear_module(UNITTEST_MODULE)
Beispiel #2
0
    def __init__(self, load_all_modules=False):

        self.config = misc.load_config('.airc')

        #
        # database
        #

        Session = sessionmaker(bind=model.engine)
        self.session = Session()

        #
        # TensorFlow (deferred, as tf can take quite a bit of time to set up)
        #

        self.tf_session = None
        self.nlp_model = None

        #
        # module management, setup
        #

        self.modules = {}
        self.initialized_modules = set()
        s = self.config.get('semantics', 'modules')
        self.all_modules = list(map(lambda s: s.strip(), s.split(',')))
        sys.path.append('modules')

        #
        # AIProlog parser, runtime
        #

        db_url = self.config.get('db', 'url')
        self.db = LogicDB(db_url)
        self.aip_parser = AIPrologParser(self)
        self.rt = AIPrologRuntime(self.db)
        self.dummyloc = SourceLocation('<rt>')

        #
        # alignment / word2vec (on-demand model loading)
        #
        self.w2v_model = None
        self.w2v_lang = None
        self.w2v_all_utterances = []

        #
        # load modules, if requested
        #
        if load_all_modules:
            for mn2 in self.all_modules:
                self.load_module(mn2)
                self.init_module(mn2)
Beispiel #3
0
    def setUp(self):
        #
        # db, store
        #

        db_url = 'sqlite:///foo.db'

        # setup compiler + environment

        self.db = LogicDB(db_url)
        self.parser = PrologParser(self.db)
        self.rt = PrologRuntime(self.db)

        self.db.clear_module(UNITTEST_MODULE)
Beispiel #4
0
    def __init__(self):

        cmdln.Cmdln.__init__(self)

        self.config = misc.load_config('.airc')

        all_modules = list(
            map(lambda m: m.strip(),
                self.config.get('semantics', 'modules').split(',')))

        db_url = self.config.get('db', 'url')
        db = LogicDB(db_url)

        self.kernal = AIKernal(db=db, all_modules=all_modules)
Beispiel #5
0
    def __init__(self):

        self.config = misc.load_config('.airc')

        #
        # database
        #

        Session = sessionmaker(bind=model.engine)
        self.session = Session()

        #
        # logic DB
        #

        self.db = LogicDB(model.url)

        #
        # knowledge base
        #

        self.kb = AIKB()

        #
        # TensorFlow (deferred, as tf can take quite a bit of time to set up)
        #

        self.tf_session = None
        self.nlp_model  = None

        #
        # module management, setup
        #

        self.modules  = {}
        s = self.config.get('semantics', 'modules')
        self.all_modules = map (lambda s: s.strip(), s.split(','))

        #
        # prolog environment setup
        #

        self.prolog_rt = AIPrologRuntime(self.db, self.kb)
        self.parser    = AIPrologParser()
    def setUp(self):

        config = misc.load_config('.airc')

        #
        # logic DB
        #

        self.db = LogicDB(model.url)

        #
        # aiprolog environment setup
        #

        self.prolog_rt = AIPrologRuntime(self.db)
        self.parser = AIPrologParser(self.db)

        self.prolog_rt.set_trace(True)

        self.db.clear_module(UNITTEST_MODULE)
Beispiel #7
0
    #
    # VAD
    #

    misc.message_popup(stdscr, 'Initializing...', 'Init VAD...')
    vad = VAD(aggressiveness=aggressiveness, sample_rate=SAMPLE_RATE)
    paint_main()
    logging.debug('VAD initialized.')

    #
    # setup AI Kernal
    #

    misc.message_popup(stdscr, 'Initializing...', 'Init AI Kernal...')
    db = LogicDB(db_url)
    kernal = AIKernal(db=db, all_modules=all_modules, load_all_modules=True)
    # kernal.setup_tf_model (mode='decode', load_model=True, ini_fn=ai_model)
    # kernal.setup_align_utterances(lang=lang)
    paint_main()
    logging.debug('AI kernal initialized.')

    #
    # context
    #

    cur_context = kernal.find_prev_context(USER_URI)

    #
    # ASR
    #