pub struct TextAnalyzer;Expand description
Text analyzer for structural analysis
Implementations§
Source§impl TextAnalyzer
impl TextAnalyzer
Sourcepub fn detect_heading_level(line: &str) -> Option<u8>
pub fn detect_heading_level(line: &str) -> Option<u8>
Detect if a line is a heading and determine its level
Supports multiple heading formats:
- Markdown: #, ##, ###, etc.
- Plain text: ALL CAPS, numeric prefixes
- Underlined text (detected by caller)
Returns Some(level) if detected, where level 1 is highest (chapter)
Sourcepub fn extract_section_number(text: &str) -> Option<SectionNumber>
pub fn extract_section_number(text: &str) -> Option<SectionNumber>
Extract section number from heading text
Recognizes patterns like:
- “1.”, “2.”, “3.”
- “1.1”, “1.2.3”, “2.3.4.5”
- “Chapter 1”, “Section 2.1”
- “I.”, “II.”, “III.” (Roman numerals)
- “A.”, “B.”, “C.” (Alphabetic)
Sourcepub fn find_blank_line_positions(text: &str) -> Vec<usize>
pub fn find_blank_line_positions(text: &str) -> Vec<usize>
Find positions of blank lines (paragraph separators)
Returns character offsets where blank lines occur
Sourcepub fn calculate_statistics(text: &str) -> TextStats
pub fn calculate_statistics(text: &str) -> TextStats
Calculate statistics about text
Sourcepub fn is_underline(line: &str) -> Option<u8>
pub fn is_underline(line: &str) -> Option<u8>
Detect if a line is underlined (for plain text heading detection)
Checks if next_line consists entirely of underline characters (=, -, _)
Sourcepub fn extract_title(text: &str) -> Option<String>
pub fn extract_title(text: &str) -> Option<String>
Extract potential title from text (first non-empty line or ALL CAPS line)
Auto Trait Implementations§
impl Freeze for TextAnalyzer
impl RefUnwindSafe for TextAnalyzer
impl Send for TextAnalyzer
impl Sync for TextAnalyzer
impl Unpin for TextAnalyzer
impl UnsafeUnpin for TextAnalyzer
impl UnwindSafe for TextAnalyzer
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more