All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliasi.test.unit.features.MockFeatureExtractor Maven / Gradle / Ivy

Go to download

This is the original Lingpipe: http://alias-i.com/lingpipe/web/download.html There were not made any changes to the source code.

There is a newer version: 4.1.2-JL1.0
Show newest version
package com.aliasi.test.unit.features;

import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

import java.util.Map;

import com.aliasi.util.FeatureExtractor;

public class MockFeatureExtractor
    extends SerializableMockFeatureExtractor {

    private void writeObject(ObjectOutputStream out) throws IOException {
        throw new NotSerializableException();
    }

    public static  void assertFeats(FeatureExtractor fe,
                                       E in,
                                       String[] feats,
                                       double[] vals) {
        Map featVec = fe.features(in);
        assertEquals(feats.length,vals.length);
        assertEquals(featVec.size(),feats.length);
        for (int i = 0; i < feats.length; ++i) {
            assertNotNull("no val for " + feats[i],featVec.get(feats[i]));
            assertEquals(feats[i],vals[i],featVec.get(feats[i]).doubleValue(),0.0001);
        }
    }

}
    




© 2015 - 2025 Weber Informatics LLC | Privacy Policy