pub struct DocumentSummarizer { /* private fields */ }Expand description
Production-quality document summarizer supporting five summarization strategies.
Implementations§
Source§impl DocumentSummarizer
impl DocumentSummarizer
Sourcepub fn new(config: SummarizerConfig) -> Self
pub fn new(config: SummarizerConfig) -> Self
Create a new summarizer with the supplied configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a summarizer with a default extractive (3-sentence) configuration.
Sourcepub fn stats(&self) -> &SummarizerStats
pub fn stats(&self) -> &SummarizerStats
Return a reference to the accumulated statistics.
Sourcepub fn summarize(
&mut self,
text: &str,
embeddings: Option<Vec<Vec<f64>>>,
) -> Result<SummaryResult, SummarizerError>
pub fn summarize( &mut self, text: &str, embeddings: Option<Vec<Vec<f64>>>, ) -> Result<SummaryResult, SummarizerError>
Summarize text using the configured strategy.
embeddings, when provided, must contain one vector per sentence in document
order and must all share the same dimension.
Sourcepub fn score_sentence(
&self,
sentence: &str,
index: usize,
total: usize,
corpus: &[Vec<String>],
) -> SentenceScore
pub fn score_sentence( &self, sentence: &str, index: usize, total: usize, corpus: &[Vec<String>], ) -> SentenceScore
Score a single sentence.
corpus holds the tokenized form of every sentence in the document (used for IDF).
Sourcepub fn extract_keyphrases(&self, text: &str, n: usize) -> Vec<String>
pub fn extract_keyphrases(&self, text: &str, n: usize) -> Vec<String>
Extract the top-n n-gram keyphrases from text.
Sourcepub fn chunk_document(
&self,
text: &str,
chunk_size: usize,
) -> Vec<DocumentChunk>
pub fn chunk_document( &self, text: &str, chunk_size: usize, ) -> Vec<DocumentChunk>
Split text into overlapping chunks of approximately chunk_size characters.
Chunks overlap by 10% of chunk_size to preserve context across boundaries.
Sourcepub fn quality_score(&self, original: &str, summary: &str) -> f64
pub fn quality_score(&self, original: &str, summary: &str) -> f64
Compute a quality score in [0, 1] as the fraction of original’s top keyphrases
that appear (as substrings) in summary.
Auto Trait Implementations§
impl Freeze for DocumentSummarizer
impl RefUnwindSafe for DocumentSummarizer
impl Send for DocumentSummarizer
impl Sync for DocumentSummarizer
impl Unpin for DocumentSummarizer
impl UnsafeUnpin for DocumentSummarizer
impl UnwindSafe for DocumentSummarizer
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.