com.aliasi.test.unit.features.SerializableMockFeatureExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliasi-lingpipe Show documentation
Show all versions of aliasi-lingpipe Show documentation
This is the original Lingpipe:
http://alias-i.com/lingpipe/web/download.html
There were not made any changes to the source code.
package com.aliasi.test.unit.features;
import com.aliasi.util.FeatureExtractor;
import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;
public class SerializableMockFeatureExtractor
implements FeatureExtractor, Serializable {
final Map> mMap = new HashMap>();
public Map features(Integer in) {
Map feats = mMap.get(in);
return feats == null
? new HashMap()
: feats;
}
public void put(int e, Map features) {
mMap.put(e,features);
}
public void put(int e, String[] feats, double[] vals) {
if (feats.length != vals.length)
throw new IllegalArgumentException();
put(e,toMap(feats,vals));
}
static Map toMap(String[] feats, double[] vals) {
Map result = new HashMap();
for (int i = 0; i < feats.length; ++i)
result.put(feats[i],vals[i]);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy