You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filter word detection — ~26 common filler words (其實、基本上、就是、然後...)
Sentiment analysis — 500+ word lexicon with negation/intensifier handling (不/沒/非常/很)
Sentence variety — segmentation-based analysis
Word segmentation — opencc-jieba-rs, supports both Traditional and Simplified Chinese
General
Zero unsafe code — memory safe by design
No runtime I/O — all data embedded at compile time
Quick Start
cargo add writing-analysis
# With Chinese support
cargo add writing-analysis --features chinese
use writing_analysis::{analyze_all, analyze_readability, detect_passive_voice};fnmain() -> writing_analysis::Result<()>{let text = "The ball was thrown by the boy. \ She ran quickly through the park. \ It was a beautiful day.";// Run all analyses at oncelet result = analyze_all(text)?;println!("Flesch Reading Ease: {:.1}", result.readability.flesch_reading_ease);println!("Passive voice: {:.0}%", result.passive_voice.percentage);println!("Cliches found: {}", result.cliches.count);println!("Filter words: {}", result.filter_words.count);println!("Sentiment: {:.2}", result.sentiment.score);println!("Sentence variety: {:.2}", result.sentence_variety.structure_variety);Ok(())}
Usage
Readability
let scores = writing_analysis::analyze_readability("The implementation of sophisticated algorithms necessitates \ comprehensive understanding of computational complexity.")?;assert!(scores.flesch_kincaid_grade > 12.0);// college levelassert!(scores.flesch_reading_ease < 30.0);// very difficult
Passive Voice
let result = writing_analysis::detect_passive_voice("The report was written by the team. She presented the findings.")?;assert_eq!(result.instances.len(),1);assert_eq!(result.instances[0].phrase,"was written");assert_eq!(result.percentage,50.0);// 1 of 2 sentences
Cliches
let result = writing_analysis::detect_cliches("At the end of the day, we need to think outside the box.")?;assert_eq!(result.count,2);for cliche in&result.instances{println!("'{}' at offset {}", cliche.canonical, cliche.offset);}
Filter Words
let result = writing_analysis::detect_filter_words("She just really wanted to basically understand.")?;assert_eq!(result.count,3);// just, really, basicallyprintln!("{:.1}% filter words", result.percentage);
Sentiment
let result = writing_analysis::analyze_sentiment("I love this wonderful movie.")?;assert!(result.score > 0.0);// positivefor token in&result.tokens{if token.score != 0{println!("{}: {}", token.word, token.score);}}
Sentence Variety
let result = writing_analysis::analyze_sentence_variety("The cat sat. The dog ran. The bird flew. A fish swam.")?;println!("Avg length: {:.1} words", result.avg_length);println!("Variety: {:.2}", result.structure_variety);// 0.5 — repetitive starters
Chinese Analysis
use writing_analysis::{analyze_all_zh, analyze_readability_zh, detect_passive_voice_zh};fnmain() -> writing_analysis::Result<()>{let text = "今天天氣很好。我們去公園散步。孩子們在草地上玩耍。";let result = analyze_all_zh(text)?;println!("SCRI: {:.1}", result.readability.scri);println!("Common char ratio: {:.1}%", result.readability.common_char_ratio);println!("Passive voice: {:.0}%", result.passive_voice.percentage);println!("Cliches: {}", result.cliches.count);println!("Filter words: {}", result.filter_words.count);println!("Sentiment: {:.2}", result.sentiment.score);Ok(())}