Exemplo n.º 1
0
    # 데이터에 토큰화 함수 적용
    # 다른 파일에 토큰화 함수가 있기에 조금 변경
    # 수행하는 결과는 github 코드와 동일합니다.
    question = preprocessor.tokenize_ko(question)
    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)