1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! 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"
//! ```
//!
//! [`Brain`]: crate::brain::Brain
//! [`BrainStats`]: crate::stats::BrainStats
//! [`Brain::stats`]: crate::brain::Brain::stats