示例#1
0
def conversation():
    with tf.Session() as sess:
        with tf.variable_scope("be_model") as scope:
            model_be = BotEngine.create_model(sess, True)
            print("be 모델 생성 완료")
        with tf.variable_scope("gg_model"):
            scope.reuse_variables()
            model_gg = GrammarGenerator.create_model(sess, True)
            print("gg 모델 생성 완료, 이어서 대화 시작")
        while True:
            try:
                query = input()
                print("나 : ", query)
            except EOFError as eofe:
                print("이만 테스트를 마칩니다.")
                break
            f_answer = BotEngine.decode(sess, model_be, query)
            print("be 모델 판단")
            i_answer = GrammarGenerator.decode(sess, model_gg, f_answer, False)
            print("gg 모델 판단")
            result = []
            for word in i_answer:
                if '/' in word:
                    result.append(word[:word.index('/')])
            answer = " ".join(result)
            print("Com : ", answer)
示例#2
0
def test_be():
    with tf.Session() as sess:
        with tf.variable_scope("be_model"):
            model = BotEngine.create_model(sess, True)
        while True:
            try :
                query = input("나 : ")
            except EOFError as eofe:
                print("\n이만 테스트를 마칩니다.")
                break
            answer = BotEngine.decode(sess, model, query)
            result = []
            for word in answer:
                if '/' in word:
                    result.append(word[:word.index('/')])
                #else :
                #    result.append(word)
            answer = " ".join(result)
            print("Com : ", answer)