forked from yinchuandong/JavaVerify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBase.java
More file actions
53 lines (44 loc) · 1.04 KB
/
Base.java
File metadata and controls
53 lines (44 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package Base;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
public class Base {
/**
* 类标号map,如:a=>1 b=>2
*/
protected HashMap<String, Integer> labelMap = null;
public Base(){
labelMap = new HashMap<String, Integer>();
loadImageLabel();
}
/**
* 加载类标号
*/
protected void loadImageLabel(){
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(new File("svm/label.txt")));
String buff = null;
while((buff = reader.readLine()) != null){
String[] arr = buff.split(" ");
labelMap.put(arr[0], Integer.parseInt(arr[1]));
}
System.out.println("load image label finish!");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally{
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}