#markov-chain #words #clone

march

A Markov chain implementation

1 unstable release

0.1.0 May 10, 2023

#20 in #markov-chain

MIT license

8KB
146 lines

March

A Markov chain crate for Rust. This implementation should work for any item that implements Hash + Eq + Clone.

Usage

use march::Chain;

fn main() {
    let mut chain = Chain::new();
    let sentence = "The quick brown fox jumped over the lazy dog".to_lowercase();
    let mut words = sentence.split_whitespace().into_iter();
    chain.feed(&mut words);

    let sentence = chain.generate();
    dbg!(sentence);
}

See examples for more usages.


lib.rs:

A Markov chain crate for Rust. This implementation should work for any item that implements Hash + Eq + Clone.

Usage

use march::Chain;

fn main() {
    let mut chain = Chain::new();
    let sentence = "The quick brown fox jumped over the lazy dog".to_lowercase();
    let mut words = sentence.split_whitespace().into_iter();
    chain.feed(&mut words);

    let sentence = chain.generate();
    dbg!(sentence);
}

Dependencies

~2MB
~34K SLoC