Skip to main content

Module document_summarizer

Module document_summarizer 

Source
Expand description

Full-featured extractive and abstractive-style document summarization.

DocumentSummarizer implements five summarization strategies driven by TF-IDF, position bias, sentence length heuristics, and optional embedding centrality:

  • Extractive — score every sentence and return the top-k in original order.
  • Keyphrase — extract the most significant 2–4-word n-gram keyphrases.
  • Headline — return the single most important sentence, truncated.
  • Abstractive — concatenate top-3 sentences with transition words stripped, trimmed to a target word count.
  • Hierarchical — cluster sentences and pick one representative per cluster.

Re-exports§

pub use ds_types::DocumentChunk;
pub use ds_types::SentenceScore;
pub use ds_types::SummarizerConfig;
pub use ds_types::SummarizerError;
pub use ds_types::SummarizerStats;
pub use ds_types::SummaryResult;
pub use ds_types::SummaryStyle;

Modules§

ds_types
Type definitions for the document summarizer.

Structs§

DocumentSummarizer
Production-quality document summarizer supporting five summarization strategies.

Functions§

cosine_similarity
Cosine similarity between two f64 slices; returns 0.0 on dimension mismatch or zero norm.
split_sentences
Split text into sentences on '. ', '! ', '? ', and '\n\n' boundaries.
tf_idf
Compute TF-IDF for term given the tokens of its document and the full corpus.
tokenize
Tokenize text into lowercase alphanumeric tokens.
xorshift64
Minimal xorshift64 PRNG; used in tests to avoid the rand crate.