MCPcopy Create free account
hub / github.com/Niko1221/Strata / window_counts

Function window_counts

engine/src/split/src/session.cpp:87–97  ·  view source on GitHub ↗

each penalized token once with its count among the last n of seq

Source from the content-addressed store, hash-verified

85namespace {
86// each penalized token once with its count among the last n of seq
87std::vector<std::pair<int, int>> window_counts(const std::vector<int>& seq, int n) {
88 std::vector<std::pair<int, int>> out;
89 const size_t start = seq.size() > (size_t) n ? seq.size() - n : 0;
90 for (size_t i = start; i < seq.size(); ++i) {
91 if (seq[i] >= Engine::IMAGE_TOK) continue; // image cells are not vocabulary tokens
92 auto it = std::find_if(out.begin(), out.end(), [&](const std::pair<int, int>& c) { return c.first == seq[i]; });
93 if (it == out.end()) out.emplace_back(seq[i], 1);
94 else ++it->second;
95 }
96 return out;
97}
98} // namespace
99
100Engine::Penalties::Row penalty_row(const std::vector<int>& seq, const Sampling& s) {

Callers 1

penalty_rowFunction · 0.85

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected