Class Word2VecModel
java.lang.Object
org.apache.lucene.analysis.synonym.word2vec.Word2VecModel
- All Implemented Interfaces:
RandomAccessVectorValues
,RandomAccessVectorValues.Floats
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 interface org.apache.lucene.util.hnsw.RandomAccessVectorValues
RandomAccessVectorValues.Bytes, RandomAccessVectorValues.Floats
-
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 thisRandomAccessVectorValues
.int
Return the dimension of the returned vector valuesint
size()
Return the number of vector valuestermValue
(int targetOrd) float[]
vectorValue
(int targetOrd) Return the vector value indexed at the given ordinal.float[]
vectorValue
(BytesRef term) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.util.hnsw.RandomAccessVectorValues
getAcceptOrds, getSlice, ordToDoc
Methods inherited from interface org.apache.lucene.util.hnsw.RandomAccessVectorValues.Floats
getVectorByteLength
-
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 interface:RandomAccessVectorValues.Floats
Return the vector value indexed at the given ordinal.- Specified by:
vectorValue
in interfaceRandomAccessVectorValues.Floats
- Parameters:
targetOrd
- a valid ordinal, ≥ 0 and <RandomAccessVectorValues.size()
.
-
vectorValue
-
termValue
-
dimension
public int dimension()Description copied from interface:RandomAccessVectorValues
Return the dimension of the returned vector values- Specified by:
dimension
in interfaceRandomAccessVectorValues
-
size
public int size()Description copied from interface:RandomAccessVectorValues
Return the number of vector values- Specified by:
size
in interfaceRandomAccessVectorValues
-
copy
Description copied from interface:RandomAccessVectorValues
Creates a new copy of thisRandomAccessVectorValues
. This is helpful when you need to access different values at once, to avoid overwriting the underlying vector returned.- Specified by:
copy
in interfaceRandomAccessVectorValues
- Specified by:
copy
in interfaceRandomAccessVectorValues.Floats
- Throws:
IOException
-