use of hex.genmodel.MojoModel in project h2o-3 by h2oai.
the class Word2VecMojoModelTest method testTransform0.
@Test
public void testTransform0() throws Exception {
MojoModel mojo = Word2VecMojoReader.readFrom(new Word2VecMojoModelTest.ClasspathReaderBackend());
assertTrue(mojo instanceof WordEmbeddingModel);
WordEmbeddingModel m = (WordEmbeddingModel) mojo;
assertEquals(3, m.getVecSize());
assertArrayEquals(new float[] { 0.0f, 1.0f, 0.2f }, m.transform0("a", new float[3]), 0.0001f);
assertArrayEquals(new float[] { 1.0f, 0.0f, 0.8f }, m.transform0("b", new float[3]), 0.0001f);
// out-of-dictionary word
assertNull(m.transform0("c", new float[3]));
}