public void loadData(String path) throws IOException { BufferedReader br = new BufferedReader(new FileReader(new File(path))); String line = br.readLine(); while (line != null) { String[] segs = line.split("\\s"); String label = segs[0]; List<String> featureList = new ArrayList<String>(); for (int i = 1; i < segs.length; ++i) { featureList.add(segs[i]); features.addFeature(label, segs[i]); } features.setMaxFeaturePerSample(featureList.size()); Sample sample = new Sample(label, featureList); sampleList.add(sample); labelSet.add(label); line = br.readLine(); } }