Package opennlp.ccg.perceptron.Alphabet

Examples of opennlp.ccg.perceptron.Alphabet.Feature


 
  /** Returns the dot product of the weights and features. */
  public double score(FeatureVector fv) {
    double retval = 0.0;
    for (FeatureVector.Iterator it = fv.iterator(); it.hasNext(); ) {
      Feature feat = it.nextFeature();
      Float value = it.nextValue();
      Integer index = feat.getIndex();
      if (index == null) continue;
      retval += weights[index] * value;
    }
    if (debug) System.err.println("score: " + retval + " " + fv);
    return retval;
View Full Code Here


  }
 
  /** Adds the feature vector values to the weights. */
  public void add(FeatureVector fv) {
    for (FeatureVector.Iterator it = fv.iterator(); it.hasNext(); ) {
      Feature feat = it.nextFeature();
      Float value = it.nextValue();
      Integer index = feat.getIndex();
      if (index == null) continue;
      weights[index] += value;
    }
  }
View Full Code Here

  }
 
  /** Subtracts the feature vector values from the weights. */
  public void subtract(FeatureVector fv) {
    for (FeatureVector.Iterator it = fv.iterator(); it.hasNext(); ) {
      Feature feat = it.nextFeature();
      Float value = it.nextValue();
      Integer index = feat.getIndex();
      if (index == null) continue;
      weights[index] -= value;
    }
  }
View Full Code Here

TOP

Related Classes of opennlp.ccg.perceptron.Alphabet.Feature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.