/** * If it hasn't been created already, this method will create the prediction feature in * {@link #predictions} associated with the label feature at the given index of * {@link #labelLexicon}. This method does not create {@link RealFeature}s in * {@link #predictions} since their strengths cannot be modified. In association with * {@link DiscreteFeature}s it creates a {@link DiscretePrimitiveStringFeature} with an empty * identifier. Its <code>value</code>, <code>valueIndex</code>, and <code>totalValues</code> * fields are filled by calling the label feature's {@link Feature#getStringValue() * getStringValue()}, {@link Feature#getValueIndex() getValueIndex()}, and * {@link Feature#totalValues() totalValues()} methods respectively. * * @param index The index of a label feature in {@link #labelLexicon}. **/ protected void createPrediction(int index) { createPrediction(labelLexicon, index); }
/** * Sets the label lexicon. * * @param l A feature lexicon. **/ public void setLabelLexicon(Lexicon l) { labelLexicon = l; if (labelLexicon == null) { predictions = null; return; } int N = labelLexicon.size(); predictions = new FVector(N); for (int i = 0; i < N; ++i) createPrediction(i); }
labelArray[f] = labelLexicon.lookup(label.getFeatureKey(labelLexicon), true); labelValues[f] += label.getStrength(); createPrediction(labelArray[f]);