92 const char * lbegin = begin;
93 const char * lend = lbegin;
94 IndexType min_feat_id = std::numeric_limits<IndexType>::max();
95 while (lbegin != end) {
98 while (lend != end && *lend !=
'\n' && *lend !=
'\r') ++lend;
100 const char * p = lbegin;
101 const char * q = NULL;
104 std::ptrdiff_t advanced = IgnoreCommentAndBlank(p, lend);
106 int r = ParsePair<real_t, real_t>(p, lend, &q, label, weight);
114 out->weight.push_back(weight);
116 if (out->label.size() != 0) {
117 out->offset.push_back(out->index.size());
119 out->label.push_back(label);
123 while (p != end && *p ==
' ') ++p;
124 if (p != lend && (strncmp(p,
"qid:", 4) == 0)) {
126 qid =
static_cast<uint64_t
>(atoll(p));
128 out->qid.push_back(qid);
134 std::ptrdiff_t advanced = IgnoreCommentAndBlank(p, lend);
136 int r = ParsePair<IndexType, real_t>(p, lend, &q, featureId, value);
143 out->index.push_back(featureId);
144 min_feat_id = std::min(featureId, min_feat_id);
147 out->value.push_back(value);
154 if (out->label.size() != 0) {
155 out->offset.push_back(out->index.size());
157 CHECK(out->label.size() + 1 == out->offset.size());
162 if (param_.indexing_mode > 0
163 || (param_.indexing_mode < 0 && !out->index.empty() && min_feat_id > 0)) {
165 for (IndexType& e : out->index) {