Class Word2VecModel
- java.lang.Object
-
- org.apache.lucene.analysis.synonym.word2vec.Word2VecModel
-
- All Implemented Interfaces:
RandomAccessVectorValues
,RandomAccessVectorValues.Floats
public class Word2VecModel extends java.lang.Object implements 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
Fields Modifier and Type Field Description private int
dictionarySize
private int
loadedCount
private TermAndVector[]
termsAndVectors
private int
vectorDimension
private BytesRefHash
word2Vec
-
Constructor Summary
Constructors Modifier Constructor Description Word2VecModel(int dictionarySize, int vectorDimension)
private
Word2VecModel(int dictionarySize, int vectorDimension, TermAndVector[] termsAndVectors, BytesRefHash word2Vec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTermAndVector(TermAndVector modelEntry)
Word2VecModel
copy()
Creates a new copy of thisRandomAccessVectorValues
.int
dimension()
Return the dimension of the returned vector valuesint
size()
Return the number of vector valuesBytesRef
termValue(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 Detail
-
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 Detail
-
Word2VecModel
public Word2VecModel(int dictionarySize, int vectorDimension)
-
Word2VecModel
private Word2VecModel(int dictionarySize, int vectorDimension, TermAndVector[] termsAndVectors, BytesRefHash word2Vec)
-
-
Method Detail
-
addTermAndVector
public void addTermAndVector(TermAndVector modelEntry)
-
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
public float[] vectorValue(BytesRef term)
-
termValue
public BytesRef termValue(int targetOrd)
-
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
public Word2VecModel copy() throws java.io.IOException
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:
java.io.IOException
-
-