| 97 | } |
| 98 | } |
| 99 | inline void ParseOneLine(const char* str, |
| 100 | std::vector<std::pair<int, double>>* out_features, double* out_label) const override { |
| 101 | int idx = 0; |
| 102 | double val = 0.0f; |
| 103 | if (label_idx_ == 0) { |
| 104 | str = Common::Atof(str, &val); |
| 105 | *out_label = val; |
| 106 | str = Common::SkipSpaceAndTab(str); |
| 107 | } |
| 108 | while (*str != '\0') { |
| 109 | str = Common::Atoi(str, &idx); |
| 110 | str = Common::SkipSpaceAndTab(str); |
| 111 | if (*str == ':') { |
| 112 | ++str; |
| 113 | str = Common::Atof(str, &val); |
| 114 | out_features->emplace_back(idx, val); |
| 115 | } else { |
| 116 | Log::Fatal("Input format error when parsing as LibSVM"); |
| 117 | } |
| 118 | str = Common::SkipSpaceAndTab(str); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | inline int NumFeatures() const override { |
| 123 | return total_columns_; |
nothing calls this directly
no test coverage detected