Package org.apache.lucene.demo.knn

## Class DemoEmbeddings

- java.lang.Object
- - org.apache.lucene.demo.knn.DemoEmbeddings

-     public class DemoEmbeddings
      extends Object

  This class provides `computeEmbedding(String)` and `computeEmbedding(Reader)` for calculating "semantic" embedding vectors for textual input.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DemoEmbeddings​(KnnVectorDict vectorDict)` | Sole constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `float[]` | `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DemoEmbeddings

          public DemoEmbeddings​(KnnVectorDict vectorDict)

      Sole constructor
      Parameters:
        `vectorDict` - a token to vector dictionary

  - ### Method Detail

    - #### computeEmbedding

          public float[] computeEmbedding​(String input)
                                   throws IOException

      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

          public float[] computeEmbedding​(Reader input)
                                   throws IOException

      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`