Class Word2VecModel
java.lang.Object
org.apache.lucene.index.KnnVectorValues
org.apache.lucene.index.FloatVectorValues
org.apache.lucene.analysis.synonym.word2vec.Word2VecModel
Word2VecModel is a class representing the parsed Word2Vec model containing the vectors for each
word in dictionary
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.index.KnnVectorValues
KnnVectorValues.DocIndexIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate intprivate final TermAndVector[]private final intprivate final BytesRefHash -
Constructor Summary
ConstructorsModifierConstructorDescriptionWord2VecModel(int dictionarySize, int vectorDimension) privateWord2VecModel(int dictionarySize, int vectorDimension, TermAndVector[] termsAndVectors, BytesRefHash word2Vec) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTermAndVector(TermAndVector modelEntry) copy()Creates a new copy of thisKnnVectorValues.intReturn the dimension of the vectorsintsize()Return the number of vectors for this field.termValue(int targetOrd) float[]vectorValue(int targetOrd) Return the vector value for the given vector ordinal which must be in [0, size() - 1], otherwise IndexOutOfBoundsException is thrown.float[]vectorValue(BytesRef term) Methods inherited from class org.apache.lucene.index.FloatVectorValues
checkField, fromFloats, getEncoding, scorerMethods inherited from class org.apache.lucene.index.KnnVectorValues
createDenseIterator, createSparseIterator, fromDISI, getAcceptOrds, getVectorByteLength, iterator, ordToDoc
-
Field Details
-
dictionarySize
private final int dictionarySize -
vectorDimension
private final int vectorDimension -
termsAndVectors
-
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
-
vectorValue
public float[] vectorValue(int targetOrd) Description copied from class:FloatVectorValuesReturn 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:
vectorValuein classFloatVectorValues- Returns:
- the vector value
-
vectorValue
-
termValue
-
dimension
public int dimension()Description copied from class:KnnVectorValuesReturn the dimension of the vectors- Specified by:
dimensionin classKnnVectorValues
-
size
public int size()Description copied from class:KnnVectorValuesReturn the number of vectors for this field.- Specified by:
sizein classKnnVectorValues- Returns:
- the number of vectors returned by this iterator
-
copy
Description copied from class:KnnVectorValuesCreates a new copy of thisKnnVectorValues. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.- Specified by:
copyin classFloatVectorValues- Throws:
IOException
-