提交 bd15912d 编写于 作者: Y YishengCheng 提交者: Tao Luo

fix bug for ctr_reader for svm data (#17575)

* fix bug for ctr_reader test=develop

* fix svm data test=develop

fix svm data test=develop
上级 8fd39f3e
...@@ -52,9 +52,9 @@ static inline void parse_line( ...@@ -52,9 +52,9 @@ static inline void parse_line(
std::unordered_map<std::string, std::vector<int64_t>>* slot_to_data) { std::unordered_map<std::string, std::vector<int64_t>>* slot_to_data) {
std::vector<std::string> ret; std::vector<std::string> ret;
string_split(line, ' ', &ret); string_split(line, ' ', &ret);
*label = std::stoi(ret[2]) > 0; *label = std::stoi(ret[0]) > 0;
for (size_t i = 3; i < ret.size(); ++i) { for (size_t i = 1; i < ret.size(); ++i) {
const std::string& item = ret[i]; const std::string& item = ret[i];
std::vector<std::string> feasign_and_slot; std::vector<std::string> feasign_and_slot;
string_split(item, ':', &feasign_and_slot); string_split(item, ':', &feasign_and_slot);
......
...@@ -91,16 +91,16 @@ static inline void check_all_data( ...@@ -91,16 +91,16 @@ static inline void check_all_data(
TEST(CTR_READER, read_data) { TEST(CTR_READER, read_data) {
const std::vector<std::string> ctr_data = { const std::vector<std::string> ctr_data = {
"aaaa 1 0 0:6002 1:6003 2:6004 3:6005 4:6006 -1\n", "0 0:6002 1:6003 2:6004 3:6005 4:6006 \n",
"bbbb 1 0 5:6003 6:6003 7:6003 8:6004 9:6004 -1\n", "0 5:6003 6:6003 7:6003 8:6004 9:6004 \n",
"cccc 1 1 10:6002 11:6002 12:6002 13:6002 14:6002 -2\n", "1 10:6002 11:6002 12:6002 13:6002 14:6002 \n",
"dddd 1 0 15:6003 16:6003 17:6003 18:6003 19:6004 -3\n", "0 15:6003 16:6003 17:6003 18:6003 19:6004 \n",
"1111 1 1 20:6001 21:6001 22:6001 23:6001 24:6001 12\n", "1 20:6001 21:6001 22:6001 23:6001 24:6001 \n",
"2222 1 1 25:6004 26:6004 27:6004 28:6005 29:6005 aa\n", "1 25:6004 26:6004 27:6004 28:6005 29:6005 \n",
"3333 1 0 30:6002 31:6003 32:6004 33:6004 34:6005 er\n", "0 30:6002 31:6003 32:6004 33:6004 34:6005 \n",
"eeee 1 1 35:6003 36:6003 37:6005 38:6005 39:6005 dd\n", "1 35:6003 36:6003 37:6005 38:6005 39:6005 \n",
"ffff 1 1 40:6002 41:6003 42:6004 43:6004 44:6005 66\n", "1 40:6002 41:6003 42:6004 43:6004 44:6005 \n",
"gggg 1 1 46:6006 45:6006 47:6003 48:6003 49:6003 ba\n", "1 46:6006 45:6006 47:6003 48:6003 49:6003 \n",
}; };
std::string gz_file_name = "test_ctr_reader_data.gz"; std::string gz_file_name = "test_ctr_reader_data.gz";
generatedata(ctr_data, gz_file_name); generatedata(ctr_data, gz_file_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册