()
| 45 | |
| 46 | |
| 47 | def get_train_set(): |
| 48 | global num_encoder_symbols, num_decoder_symbols |
| 49 | train_set = [] |
| 50 | with open('./samples/question', 'r') as question_file: |
| 51 | with open('./samples/answer', 'r') as answer_file: |
| 52 | while True: |
| 53 | question = question_file.readline() |
| 54 | answer = answer_file.readline() |
| 55 | if question and answer: |
| 56 | question = question.strip() |
| 57 | answer = answer.strip() |
| 58 | |
| 59 | question_id_list = get_id_list_from(question) |
| 60 | answer_id_list = get_id_list_from(answer) |
| 61 | if len(question_id_list) > 0 and len(answer_id_list) > 0: |
| 62 | answer_id_list.append(EOS_ID) |
| 63 | train_set.append([question_id_list, answer_id_list]) |
| 64 | else: |
| 65 | break |
| 66 | return train_set |
| 67 | |
| 68 | |
| 69 | def get_samples(train_set, batch_num): |
no test coverage detected