//! Lexical density metric — content words over total words, per paragraph.
usecrate::domain::{Document, ParagraphKind};usecrate::stopwords::is_stop_word;/// Populate `ParagraphMetrics::lexical_density` for every non-empty,
/// paragraph that is not a quote.
pub(crate)fncompute(analysis:&mut Document){for para in analysis.paragraphs_mut(){if para.word_count()==0|| para.kind ==ParagraphKind::Quote {continue;}let words:Vec<&str>= para.text.split_whitespace().collect();let total = words.len()asf64;if total ==0.0{continue;}let content = words
.iter().filter(|w|{let clean:String= w.chars().filter(|c|c.is_alphabetic()).collect();let lower = clean.to_lowercase();!lower.is_empty()&&!is_stop_word(&lower)}).count()asf64;
para.metrics.lexical_density =Some(content / total);}}