Example usage for edu.stanford.nlp.stats Counters multiplyInPlace

List of usage examples for edu.stanford.nlp.stats Counters multiplyInPlace

Introduction

In this page you can find the example usage for edu.stanford.nlp.stats Counters multiplyInPlace.

Prototype

public static <E> Counter<E> multiplyInPlace(Counter<E> target, Counter<E> mult) 

Source Link

Document

Multiplies each value in target by the count of the key in mult, in place.

Usage

From source file:gr.aueb.cs.nlp.wordtagger.classifier.SVMWindows64Factory.java

License:Open Source License

/**
 * Takes all the support vectors, and their corresponding alphas, and computes a weight
 * vector that can be used in a vanilla LinearClassifier.  This only works because
 * we are using a linear kernel.  The Counter is over the feature indices (+1 cos for
 * some reason svm_light is 1-indexed), not features.
 */// www.  j  av  a  2 s  .  c  o m
private static ClassicCounter<Integer> getWeights(List<Pair<Double, ClassicCounter<Integer>>> supportVectors) {
    ClassicCounter<Integer> weights = new ClassicCounter<Integer>();
    for (Pair<Double, ClassicCounter<Integer>> sv : supportVectors) {
        ClassicCounter<Integer> c = new ClassicCounter<Integer>(sv.second());
        Counters.multiplyInPlace(c, sv.first());
        Counters.addInPlace(weights, c);
    }
    return weights;
}