Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjolnyr/rustkov
A Markov chain chatbot library written in rust
https://github.com/kjolnyr/rustkov
Last synced: about 1 month ago
JSON representation
A Markov chain chatbot library written in rust
- Host: GitHub
- URL: https://github.com/kjolnyr/rustkov
- Owner: Kjolnyr
- Created: 2022-11-09T10:39:46.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-09T16:36:03.000Z (about 2 years ago)
- Last Synced: 2024-11-02T10:32:01.232Z (about 2 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rustkov
Rustkov is a Rust library aiming to build chatbots using a markov chain.
# Example
```rust
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:
```toml
[dependencies]
rustkov = "0.1.0"
```