MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / Example

Class Example

include/ctranslate2/batch_reader.h:21–49  ·  view source on GitHub ↗

An example is a collection of sequences or streams (e.g. source and target).

Source from the content-addressed store, hash-verified

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.

Callers 1

get_next_exampleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected