
com.aliasi.test.unit.features.PrefixedFeatureExtractorTest 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.features.PrefixedFeatureExtractor;
import com.aliasi.util.AbstractExternalizable;
import com.aliasi.util.FeatureExtractor;
import com.aliasi.util.ObjectToDoubleMap;
import static com.aliasi.test.unit.features.MockFeatureExtractor.assertFeats;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import java.io.IOException;
import java.io.NotSerializableException;
import java.util.Map;
public class PrefixedFeatureExtractorTest {
@Test
public void testAll() throws IOException {
SerializableMockFeatureExtractor fe = new SerializableMockFeatureExtractor();
fe.put(15,
new String[] { "a", "b", "c" },
new double[] { 1.5, 2.0, 3.0});
fe.put(12,
new String[0],
new double[0]);
assertNotNull(AbstractExternalizable.serializeDeserialize(fe));
PrefixedFeatureExtractor pfe
= new PrefixedFeatureExtractor("pref_", fe);
Map featMap = pfe.features(Integer.valueOf(15));
assertFeats(pfe,
Integer.valueOf(15),
new String[] { "pref_a", "pref_b", "pref_c" },
new double[] { 1.5, 2.0, 3.0});
assertFeats(pfe,
Integer.valueOf(12),
new String[] { },
new double[] { });
@SuppressWarnings("unchecked")
FeatureExtractor pfeDeser
= (FeatureExtractor)
AbstractExternalizable.serializeDeserialize(pfe);
assertFeats(pfeDeser,
Integer.valueOf(15),
new String[] { "pref_a", "pref_b", "pref_c" },
new double[] { 1.5, 2.0, 3.0});
assertFeats(pfeDeser,
Integer.valueOf(12),
new String[] { },
new double[] { });
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy