MCPcopy Create free account
hub / github.com/bwaldvogel/liblinear-java / main

Method main

src/main/java/de/bwaldvogel/liblinear/Predict.java:146–187  ·  view source on GitHub ↗
(String[] argv)

Source from the content-addressed store, hash-verified

144 }
145
146 public static void main(String[] argv) throws IOException {
147 // Note: This flag is _static_ in predict.c but it causes a thread-safety issue as reported in https://github.com/bwaldvogel/liblinear-java/issues/38
148 boolean flag_predict_probability = false;
149 int i;
150
151 // parse options
152 for (i = 0; i < argv.length; i++) {
153 if (argv[i].charAt(0) != '-')
154 break;
155 ++i;
156 switch (argv[i - 1].charAt(1)) {
157 case 'b':
158 try {
159 flag_predict_probability = (atoi(argv[i]) != 0);
160 } catch (NumberFormatException e) {
161 exit_with_help();
162 }
163 break;
164
165 case 'q':
166 i--;
167 Linear.disableDebugOutput();
168 break;
169
170 default:
171 System.err.printf("unknown option: -%d%n", argv[i - 1].charAt(1));
172 exit_with_help();
173 break;
174 }
175 }
176 if (i >= argv.length || argv.length <= i + 2) {
177 exit_with_help();
178 }
179
180 try (FileInputStream in = new FileInputStream(argv[i]);
181 BufferedReader reader = new BufferedReader(new InputStreamReader(in, Linear.FILE_CHARSET));
182 FileOutputStream out = new FileOutputStream(argv[i + 2]);
183 Writer writer = new BufferedWriter(new OutputStreamWriter(out, Linear.FILE_CHARSET))) {
184 Model model = Linear.loadModel(Paths.get(argv[i + 1]));
185 doPredict(reader, writer, model, flag_predict_probability);
186 }
187 }
188}

Callers 1

testTrainAndPredictMethod · 0.95

Calls 7

exit_with_helpMethod · 0.95
disableDebugOutputMethod · 0.95
loadModelMethod · 0.95
doPredictMethod · 0.95
atoiMethod · 0.80
printfMethod · 0.80
getMethod · 0.45

Tested by 1

testTrainAndPredictMethod · 0.76