| 133 | } |
| 134 | |
| 135 | bool Add(const std::pair<std::string, int64_t> &sentence) { |
| 136 | if (spec_->input_sentence_size() == 0) { |
| 137 | sentences_->emplace_back(sentence); |
| 138 | } else { |
| 139 | if (spec_->shuffle_input_sentence()) { |
| 140 | sampler_->Add(sentence); |
| 141 | } else { |
| 142 | sentences_->emplace_back(sentence); |
| 143 | if (sentences_->size() >= spec_->input_sentence_size()) return false; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if (total_size() > 0 && total_size() % kTooBigSentencesSize == 0) { |
| 148 | LOG(INFO) << "Loaded " << total_size() << " lines"; |
| 149 | } |
| 150 | |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | size_t total_size() const { |
| 155 | return sampler_.get() ? sampler_->total_size() : sentences_->size(); |
no test coverage detected