rustkov

Crates.iorustkov
lib.rsrustkov
version0.1.0
sourcesrc
created_at2022-11-09 16:39:08.329201
updated_at2022-11-09 16:39:08.329201
descriptionMarkov chain chatbot library
homepagehttps://github.com/kjolnyr/rustkov
repositoryhttps://github.com/kjolnyr/rustkov.git
max_upload_size
id708863
size26,571
(Kjolnyr)

documentation

README

Rustkov

Rustkov is a Rust library aiming to build chatbots using a markov chain.

Example

use rustkov::prelude::*;

fn main() -> Result<()> {
    // Create a new brain which contains the markov chain
    let mut brain = Brain::new()
        // train him with a dataset
        .from_dataset("path/to/your/dataset.txt")?
        .get();

    // As we didn't specify a config file to the brain,
    // we need to adjust config options here.
    // For instance, let's make it so it can learn from inputs.
    brain.config.training = true;

    // `brain.generate` returns an option, as the reply_chance config might
    // be less than 1.
    if let Some(response) = brain.generate("Hello there!")? {
        println!("{}", response);
    }

    // Get a reference to a BrainStats struct, computing statistics for a given brain
    let stats = brain.stats();

    println!("I know {} words!", stats.get_total_words());

    Ok(())
}

Installation

Add the following to your Cargo.toml file:

[dependencies]
rustkov = "0.1.0"
Commit count: 2

cargo fmt