Package org.apache.lucene.demo.knn
Class DemoEmbeddings
java.lang.Object
org.apache.lucene.demo.knn.DemoEmbeddings
This class provides
computeEmbedding(String)
and computeEmbedding(Reader)
for
calculating "semantic" embedding vectors for textual input.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat[]
computeEmbedding
(Reader input) Tokenize and lower-case the input, look up the tokens in the dictionary, and sum the token vectors.float[]
computeEmbedding
(String input) Tokenize and lower-case the input, look up the tokens in the dictionary, and sum the token vectors.
-
Constructor Details
-
DemoEmbeddings
Sole constructor- Parameters:
vectorDict
- a token to vector dictionary
-
-
Method Details
-
computeEmbedding
Tokenize and lower-case the input, look up the tokens in the dictionary, and sum the token vectors. Unrecognized tokens are ignored. The resulting vector is normalized to unit length.- Parameters:
input
- the input to analyze- Returns:
- the KnnVector for the input
- Throws:
IOException
-
computeEmbedding
Tokenize and lower-case the input, look up the tokens in the dictionary, and sum the token vectors. Unrecognized tokens are ignored. The resulting vector is normalized to unit length.- Parameters:
input
- the input to analyze- Returns:
- the KnnVector for the input
- Throws:
IOException
-