Expand description
Rustkov is a Rust library aiming to build chatbots using a markov chain.
The main struct, called Brain
, is in charge of interacting with the markov chain.
All you need to do it feed it data, and it will spit out something related to it.
There’s also a struct called BrainStats
to have statistics about the brain data.
You can get a BrainStats
reference using Brain::stats
.
§Examples
use rustkov::prelude::*;
fn main() -> Result<()> {
// The brain is created using composition.
let mut brain = Brain::new()
.from_dataset("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);
}
}
§Installation
Add the following to your Cargo.toml
file:
[dependencies]
rustkov = "0.1.0"