Expand description
§markovify-rs
A Rust implementation of a Markov chain text generator, inspired by markovify.
Markovify-rs is a simple, extensible Markov chain generator. Its primary use is for building Markov models of large corpora of text and generating random sentences from that.
§Basic Usage
use markovify_rs::Text;
// Build the model
let text = "Hello world. This is a test. The quick brown fox jumps.";
let model = Text::new(text, 2, true, true, None).unwrap();
// Generate a random sentence
if let Some(sentence) = model.make_sentence(None, None, None, None, None, None, None) {
println!("{}", sentence);
}
// Generate a short sentence
if let Some(sentence) = model.make_short_sentence(100, None, None, None, None, None, None, None, None) {
println!("Short: {}", sentence);
}§Features
- Configurable state size
- Sentence generation with overlap detection
- Model compilation for faster generation
- Model combination with weights
- JSON export/import for persistence
- Newline-delimited text support
Re-exports§
pub use chain::Chain;pub use chain::BEGIN;pub use chain::END;pub use errors::MarkovError;pub use errors::Result;pub use splitters::split_into_sentences;pub use text::NewlineText;pub use text::Text;pub use utils::combine_chains;pub use utils::combine_models;pub use utils::combine_texts;pub use utils::CombinedResult;pub use utils::ModelRef;
Modules§
- chain
- Markov chain implementation
- errors
- Error types for markov-rs
- splitters
- Sentence splitting utilities
- text
- Text processing and sentence generation
- utils
- Utility functions for combining models
Constants§
- VERSION
- Library version