Class EmbeddedSentence

java.lang.Object
com.redis.vl.extensions.summarization.EmbeddedSentence
All Implemented Interfaces:
org.apache.commons.math3.ml.clustering.Clusterable

public class EmbeddedSentence extends Object implements org.apache.commons.math3.ml.clustering.Clusterable
A sentence with its embedding, implementing Clusterable for k-means.
  • Constructor Details

    • EmbeddedSentence

      public EmbeddedSentence(int index, float[] embedding)
      Create an embedded sentence.
      Parameters:
      index - Original index in the sentence list (for preserving order)
      embedding - The BERT embedding as float array
  • Method Details

    • index

      public int index()
      Get the original index of this sentence.
    • getPoint

      public double[] getPoint()
      Get the embedding as double array (required by Clusterable).
      Specified by:
      getPoint in interface org.apache.commons.math3.ml.clustering.Clusterable
    • cosineSimilarity

      public double cosineSimilarity(EmbeddedSentence other)
      Calculate cosine similarity with another embedded sentence.