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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecosineSimilarity(EmbeddedSentence other) Calculate cosine similarity with another embedded sentence.double[]getPoint()Get the embedding as double array (required by Clusterable).intindex()Get the original index of this sentence.
-
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:
getPointin interfaceorg.apache.commons.math3.ml.clustering.Clusterable
-
cosineSimilarity
Calculate cosine similarity with another embedded sentence.
-