Class DemoEmbeddings

    • 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