protected List<Candidate> initCands(List<Integer> feats) { List<Candidate> cands = new ArrayList<Candidate>(); for (Integer label : LabelLib.getCandidateLabels()) { if (labelToCandidate.containsKey(label)) labelToCandidate.get(label); cands.add(labelToCandidate.get(label)); } return cands; }
protected List<ScoreLabel> initScoreLabels(List<Integer> feats) throws Exception { List<ScoreLabel> scoreLabels = new ArrayList<ScoreLabel>(); for (Integer label : LabelLib.getCandidateLabels()) { registerAllFeaturesForLabel(feats, label); ScoreLabel sc = new ScoreLabel(labelToCandidate.get(label)); sc.setScore(sc.getC().getScore(feats)); scoreLabels.add(sc); } return scoreLabels; }
public void readWeights(BufferedReader fis) throws IOException { String line = null; while ((line = fis.readLine()) != null) { String tokens[] = line.split("\t"); String intermediateFeature[] = tokens[0].split(Perceptron.DEFAULT_SEPERATOR); int label = Integer.parseInt(intermediateFeature[0]); int featureId = Integer.parseInt(intermediateFeature[1]); addNewFeature(featureId, label, Double.parseDouble(tokens[1]), true); // NB need to register label if missing LabelLib.storeLabel(Integer.parseInt(tokens[0].split(Perceptron.DEFAULT_SEPERATOR)[0])); } }