sys.path.append('/Users/wxg12/Documents/python_workspace/chatbot/') from config.DatabaseConfig import * from utils.Database import Database from utils.Preprocess import Preprocess # 전처리 객체 생성 p = Preprocess(word2index_dic='train_tools/dict/chatbot_dict.bin', userdic='utils/user_dic.tsv') # 질문/답변 학습 디비 연결 객체 생성 db = Database(host=DB_HOST, user=DB_USER, password=DB_PASSWORD, db_name=DB_NAME) db.connect() # 디비 연결 # 원문 # query = "오전에 탕수육 10개 주문합니다" # query = "화자의 질문 의도를 파악합니다." # query = "안녕하세요" query = "자장면 주문할게요" # 의도 파악 from models.intent.IntentModel import IntentModel intent = IntentModel(model_name='models/intent/intent_model.h5', proprocess=p) predict = intent.predict_class(query) intent_name = intent.labels[predict] # 개체명 인식
from config.DatabaseConfig import * from utils.Database import Database from utils.Preprocess import Preprocess # 전처리 객체 생성 p = Preprocess(word2index_dic='../train_tools/dict/chatbot_dict.bin', userdic='../utils/user_dic.tsv') # 질문/답변 학습 DB 연결 객체 생성 db = Database(host=DB_HOST, user=DB_USER, password=DB_PASSWORD, db_name=DB_NAME) db.connect() # DB 연결 # 원문 query = input() # 의도 파악 from models.intent.IntentModel import IntentModel intent = IntentModel(model_name='../models/intent/intent_model.h5', preprocess=p) predict = intent.predict_class(query) intent_name = intent.labels[predict] # 개체명 인식 from models.ner.NerModel import NerModel ner = NerModel(model_name='../models/ner/ner_model.h5', preprocess=p) predicts = ner.predict(query) ner_tags = ner.predict_tags(query)