An example is a collection of sequences or streams (e.g. source and target).
| 19 | |
| 20 | // An example is a collection of sequences or streams (e.g. source and target). |
| 21 | struct Example { |
| 22 | std::vector<std::vector<std::string>> streams; |
| 23 | |
| 24 | Example() = default; |
| 25 | |
| 26 | Example(std::vector<std::string> sequence) { |
| 27 | streams.emplace_back(std::move(sequence)); |
| 28 | } |
| 29 | |
| 30 | Example(std::vector<std::string> source, std::vector<std::string> target) { |
| 31 | streams.reserve(2); |
| 32 | streams.emplace_back(std::move(source)); |
| 33 | streams.emplace_back(std::move(target)); |
| 34 | } |
| 35 | |
| 36 | size_t num_streams() const { |
| 37 | return streams.size(); |
| 38 | } |
| 39 | |
| 40 | bool empty() const { |
| 41 | return streams.empty(); |
| 42 | } |
| 43 | |
| 44 | size_t length(size_t index = 0) const { |
| 45 | if (index >= streams.size()) |
| 46 | return 0; |
| 47 | return streams[index].size(); |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | // Base class to produce batches. |