public class Word2VecModel extends FloatVectorValues
Word2VecModel is a class representing the parsed Word2Vec model containing the vectors for each word in dictionary
  • Field Details

    • dictionarySize

      private final int dictionarySize
    • vectorDimension

      private final int vectorDimension
    • termsAndVectors

      private final TermAndVector[] termsAndVectors
    • word2Vec

      private final BytesRefHash word2Vec
    • loadedCount

      private int loadedCount
  • Constructor Details

    • Word2VecModel

      public Word2VecModel(int dictionarySize, int vectorDimension)
    • Word2VecModel

      private Word2VecModel(int dictionarySize, int vectorDimension, TermAndVector[] termsAndVectors, BytesRefHash word2Vec)
  • Method Details

    • addTermAndVector

      public void addTermAndVector(TermAndVector modelEntry)
    • vectorValue

      public float[] vectorValue(int targetOrd)
      Description copied from class: FloatVectorValues
      Return the vector value for the given vector ordinal which must be in [0, size() - 1], otherwise IndexOutOfBoundsException is thrown. The returned array may be shared across calls.
      Specified by:
      vectorValue in class FloatVectorValues
      Returns:
      the vector value
    • vectorValue

      public float[] vectorValue(BytesRef term)
    • termValue

      public BytesRef termValue(int targetOrd)
    • dimension

      public int dimension()
      Description copied from class: KnnVectorValues
      Return the dimension of the vectors
      Specified by:
      dimension in class KnnVectorValues
    • size

      public int size()
      Description copied from class: KnnVectorValues
      Return the number of vectors for this field.
      Specified by:
      size in class KnnVectorValues
      Returns:
      the number of vectors returned by this iterator
    • copy

      public Word2VecModel copy() throws IOException
      Description copied from class: KnnVectorValues
      Creates a new copy of this KnnVectorValues. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.
      Specified by:
      copy in class FloatVectorValues
      Throws:
      IOException