| 29 | } |
| 30 | |
| 31 | int GetLabelIdxForLibsvm(const std::string& str, int num_features, int label_idx) { |
| 32 | if (num_features <= 0) { |
| 33 | return label_idx; |
| 34 | } |
| 35 | auto str2 = Common::Trim(str); |
| 36 | auto pos_space = str2.find_first_of(" \f\n\r\t\v"); |
| 37 | auto pos_colon = str2.find_first_of(":"); |
| 38 | if (pos_space == std::string::npos || pos_space < pos_colon) { |
| 39 | return label_idx; |
| 40 | } else { |
| 41 | return -1; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | int GetLabelIdxForTSV(const std::string& str, int num_features, int label_idx) { |
| 46 | if (num_features <= 0) { |