MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / ParseOneLine

Method ParseOneLine

src/io/parser.hpp:99–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers

nothing calls this directly

Calls 3

AtofFunction · 0.50
SkipSpaceAndTabFunction · 0.50
AtoiFunction · 0.50

Tested by

no test coverage detected