Exemplo n.º 1
0
    answer = preprocessor.tokenize_ko(answer)

    # sentences 리스트 = 질문과 대답 리스트를 합친 것
    sentences = []
    sentences.extend(question)
    sentences.extend(answer)

    # 단어와 인덱스의 딕셔너리 생성
    # 다른 파일에 단어 생성 함수가 있기에 조금 변경
    # 수행하는 결과는 github 코드와 동일합니다.
    word_to_index, index_to_word = preprocessor.build_vocab(sentences)

    # 다른 파일에 단어 생성 함수가 있기에 조금 변경
    # 수행하는 결과는 github 코드와 동일합니다.
    # 인코더 입력 인덱스 변환
    x_encoder = preprocessor.convert_text_to_index(question, word_to_index,
                                                   ENCODER_INPUT)

    # 디코더 입력 인덱스 변환
    x_decoder = preprocessor.convert_text_to_index(answer, word_to_index,
                                                   DECODER_INPUT)

    # 디코더 목표 인덱스 변환
    y_decoder = preprocessor.convert_text_to_index(answer, word_to_index,
                                                   DECODER_TARGET)

    # 원핫 인코딩
    y_decoder = preprocessor.one_hot_encode(y_decoder)

    # 훈련 모델 인코더, 디코더 정의
    # 모델을 객체화 했기 때문에 객체로 가져오는 코드
    encoder = Encoder(len(preprocessor.words))