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 int
private int
private final TermAndVector[]
private final int
private final BytesRefHash
-
Constructor Summary
ConstructorsModifierConstructorDescriptionWord2VecModel
(int dictionarySize, int vectorDimension) private
Word2VecModel
(int dictionarySize, int vectorDimension, TermAndVector[] termsAndVectors, BytesRefHash word2Vec) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTermAndVector
(TermAndVector modelEntry) copy()
Creates a new copy of thisKnnVectorValues
.int
Return the dimension of the vectorsint
size()
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, scorer
Methods 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: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 classFloatVectorValues
- Returns:
- the vector value
-
vectorValue
-
termValue
-
dimension
public int dimension()Description copied from class:KnnVectorValues
Return the dimension of the vectors- Specified by:
dimension
in classKnnVectorValues
-
size
public int size()Description copied from class:KnnVectorValues
Return the number of vectors for this field.- Specified by:
size
in classKnnVectorValues
- Returns:
- the number of vectors returned by this iterator
-
copy
Description copied from class:KnnVectorValues
Creates 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:
copy
in classFloatVectorValues
- Throws:
IOException
-