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

hex.genmodel.algos.word2vec.Word2VecMojoModel Maven / Gradle / Ivy

There is a newer version: 3.46.0.6
Show newest version
package hex.genmodel.algos.word2vec;

import hex.genmodel.MojoModel;

import java.util.HashMap;

public class Word2VecMojoModel extends MojoModel implements WordEmbeddingModel {

  int _vecSize;
  HashMap _embeddings;

  Word2VecMojoModel(String[] columns, String[][] domains, String responseName) {
    super(columns, domains, responseName);
  }

  @Override
  public int getVecSize() {
    return _vecSize;
  }

  @Override
  public float[] transform0(String word, float[] output) {
    float[] vec = _embeddings.get(word);
    if (vec == null)
      return null;
    System.arraycopy(vec, 0, output, 0, output.length);
    return output;
  }

  @Override
  public double[] score0(double[] row, double[] preds) {
    throw new UnsupportedOperationException("Word2Vec Model doesn't support scoring using score0() function");
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy