Search in sources :

Example 1 with SparseFeatureVector

use of edu.illinois.cs.cogcomp.sl.util.SparseFeatureVector in project cogcomp-nlp by CogComp.

the class LabeledDepFeatureGenerator method featureVectorBufferFromFeature.

private FeatureVectorBuffer featureVectorBufferFromFeature(Set<Feature> features) {
    Map<String, Float> featureMap = new HashMap<>();
    for (Feature f : features) {
        if (lm.containFeature(f.getName()))
            featureMap.put(f.getName(), f.getValue());
    }
    SparseFeatureVector sfv = (SparseFeatureVector) lm.convertToFeatureVector(featureMap);
    return new FeatureVectorBuffer(sfv);
}
Also used : SparseFeatureVector(edu.illinois.cs.cogcomp.sl.util.SparseFeatureVector) HashMap(java.util.HashMap) FeatureVectorBuffer(edu.illinois.cs.cogcomp.sl.util.FeatureVectorBuffer) Feature(edu.illinois.cs.cogcomp.edison.features.Feature) DiscreteFeature(edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)

Aggregations

DiscreteFeature (edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)1 Feature (edu.illinois.cs.cogcomp.edison.features.Feature)1 FeatureVectorBuffer (edu.illinois.cs.cogcomp.sl.util.FeatureVectorBuffer)1 SparseFeatureVector (edu.illinois.cs.cogcomp.sl.util.SparseFeatureVector)1 HashMap (java.util.HashMap)1