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 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 thisRandomAccessVectorValues.intReturn the dimension of the returned vector valuesintsize()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, waitMethods inherited from interface org.apache.lucene.util.hnsw.RandomAccessVectorValues
getAcceptOrds, getSlice, ordToDocMethods 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.FloatsReturn the vector value indexed at the given ordinal.- Specified by:
vectorValuein interfaceRandomAccessVectorValues.Floats- Parameters:
targetOrd- a valid ordinal, ≥ 0 and <RandomAccessVectorValues.size().
-
vectorValue
-
termValue
-
dimension
public int dimension()Description copied from interface:RandomAccessVectorValuesReturn the dimension of the returned vector values- Specified by:
dimensionin interfaceRandomAccessVectorValues
-
size
public int size()Description copied from interface:RandomAccessVectorValuesReturn the number of vector values- Specified by:
sizein interfaceRandomAccessVectorValues
-
copy
Description copied from interface:RandomAccessVectorValuesCreates 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:
copyin interfaceRandomAccessVectorValues- Specified by:
copyin interfaceRandomAccessVectorValues.Floats- Throws:
IOException
-