MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / parse_command_line

Method parse_command_line

src/thundersvm/cmdparser.cpp:59–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void CMDParser::parse_command_line(int argc, char **argv) {
60 param_cmd.weight_label = NULL;
61 param_cmd.weight = NULL;
62 int i;
63 string bin_name = argv[0];
64#ifdef _WIN32
65 bin_name = bin_name.substr(bin_name.find_last_of("\\") + 1);
66#else
67 bin_name = bin_name.substr(bin_name.find_last_of("/") + 1);
68#endif
69 if (bin_name == "thundersvm-train" || bin_name == "thundersvm-train.exe") {
70 // parse options
71 for (i = 1; i < argc; i++) {
72 if (argv[i][0] != '-') break;
73 if (++i >= argc)
74 HelpInfo_svmtrain();
75 switch (argv[i - 1][1]) {
76
77 case 's':
78 param_cmd.svm_type = static_cast<SvmParam::SVM_TYPE>(atoi(argv[i]));
79 break;
80 case 't':
81 param_cmd.kernel_type = static_cast<SvmParam::KERNEL_TYPE>(atoi(argv[i]));
82 break;
83 case 'd':
84 param_cmd.degree = atoi(argv[i]);
85 break;
86 case 'g': {//handle fraction
87 string str_argv(argv[i]);
88 int slash = (int) str_argv.find("/", 0);
89 if (slash != string::npos) {
90 float_type numerator = atof(str_argv.substr(0, slash).c_str());
91 float_type denominator = atof(str_argv.substr(slash + 1).c_str());
92 param_cmd.gamma = numerator / denominator;
93 } else
94 param_cmd.gamma = atof(argv[i]);
95 }
96 gamma_set = true;
97 break;
98 case 'r':
99 param_cmd.coef0 = atof(argv[i]);
100 break;
101 case 'n':
102 param_cmd.nu = atof(argv[i]);
103 break;
104 case 'm':
105 param_cmd.max_mem_size = static_cast<size_t>(max(atoi(argv[i]), 0)) << 20;//MB to Byte
106 break;
107 case 'c':
108 param_cmd.C = atof(argv[i]);
109 break;
110 case 'e':
111 param_cmd.epsilon = atof(argv[i]);
112 break;
113 case 'p':
114 param_cmd.p = atof(argv[i]);
115 break;
116 case 'h':

Callers 5

read_cmdMethod · 0.80
mainFunction · 0.80
thundersvm_trainFunction · 0.80
thundersvm_predictFunction · 0.80
mainFunction · 0.80

Calls 3

HelpInfo_svmtrainFunction · 0.85
maxFunction · 0.85
HelpInfo_svmpredictFunction · 0.85

Tested by 1

read_cmdMethod · 0.64