(voc, pair_batch)
| 527 | |
| 528 | # Returns all items for a given batch of pairs |
| 529 | def batch2TrainData(voc, pair_batch): |
| 530 | pair_batch.sort(key=lambda x: len(x[0].split(" ")), reverse=True) |
| 531 | input_batch, output_batch = [], [] |
| 532 | for pair in pair_batch: |
| 533 | input_batch.append(pair[0]) |
| 534 | output_batch.append(pair[1]) |
| 535 | inp, lengths = inputVar(input_batch, voc) |
| 536 | output, mask, max_target_len = outputVar(output_batch, voc) |
| 537 | return inp, lengths, output, mask, max_target_len |
| 538 | |
| 539 | |
| 540 | # Example for validation |
no test coverage detected