pub struct SemanticSummaryExtractor { /* private fields */ }Expand description
Extractive summariser driven by sentence embeddings.
Implementations§
Source§impl SemanticSummaryExtractor
impl SemanticSummaryExtractor
Sourcepub fn new(config: ExtractorSummaryConfig) -> Self
pub fn new(config: ExtractorSummaryConfig) -> Self
Create a new extractor with the given configuration.
Sourcepub fn extract(
&mut self,
sentences: &[(String, Vec<f64>)],
query_embedding: Option<&[f64]>,
) -> Result<ExtractionResult, String>
pub fn extract( &mut self, sentences: &[(String, Vec<f64>)], query_embedding: Option<&[f64]>, ) -> Result<ExtractionResult, String>
Extract the most representative sentences.
sentences is a slice of (text, embedding) pairs. If
query_embedding is provided the initial scores are cosine similarities
to the query; otherwise centrality scores are used.
Sourcepub fn cosine_similarity(a: &[f64], b: &[f64]) -> f64
pub fn cosine_similarity(a: &[f64], b: &[f64]) -> f64
Cosine similarity between two vectors.
Returns 0.0 when either vector has zero magnitude.
Sourcepub fn centrality_scores(embeddings: &[Vec<f64>]) -> Vec<f64>
pub fn centrality_scores(embeddings: &[Vec<f64>]) -> Vec<f64>
Average cosine similarity of each embedding to all others (centrality).
Sourcepub fn coverage(selected: &[Vec<f64>], all: &[Vec<f64>]) -> f64
pub fn coverage(selected: &[Vec<f64>], all: &[Vec<f64>]) -> f64
Coverage: for each sentence in all, compute the maximum cosine similarity
to any sentence in selected, then return the average of those maxima.
Sentences that are themselves in selected are included in the average
(their max similarity to a selected sentence is trivially 1.0).
Sourcepub fn stats(&self) -> SummaryExtractorStats
pub fn stats(&self) -> SummaryExtractorStats
Return cumulative statistics.
Auto Trait Implementations§
impl Freeze for SemanticSummaryExtractor
impl RefUnwindSafe for SemanticSummaryExtractor
impl Send for SemanticSummaryExtractor
impl Sync for SemanticSummaryExtractor
impl Unpin for SemanticSummaryExtractor
impl UnsafeUnpin for SemanticSummaryExtractor
impl UnwindSafe for SemanticSummaryExtractor
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.