pub struct MarkovTextModel<const CONTEXT_LENGTH: usize = 1> { /* private fields */ }
Implementations§
Source§impl<const CONTEXT_LENGTH: usize> MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> MarkovTextModel<CONTEXT_LENGTH>
Sourcepub fn new() -> MarkovTextModel<CONTEXT_LENGTH>
pub fn new() -> MarkovTextModel<CONTEXT_LENGTH>
Creates an empty character based MarkovTextModel, where the CONTEXT_LENGTH
parameter is the context length in characters.
Examples found in repository?
examples/basic.rs (line 9)
3fn main() {
4 let sample_texts = ["Math is dumb", "Timo is cool"]
5 .iter()
6 .map(|&s| s.to_string())
7 .collect();
8
9 let mut model = MarkovTextModel::<4>::new();
10 model.add_sample_texts(&sample_texts);
11
12 for _ in 0..200 {
13 let message = model.generage_text();
14
15 println!("{message}");
16 }
17}
pub fn add_sample_text(&mut self, text: &str)
Sourcepub fn add_sample_texts(&mut self, texts: &Vec<String>)
pub fn add_sample_texts(&mut self, texts: &Vec<String>)
Examples found in repository?
examples/basic.rs (line 10)
3fn main() {
4 let sample_texts = ["Math is dumb", "Timo is cool"]
5 .iter()
6 .map(|&s| s.to_string())
7 .collect();
8
9 let mut model = MarkovTextModel::<4>::new();
10 model.add_sample_texts(&sample_texts);
11
12 for _ in 0..200 {
13 let message = model.generage_text();
14
15 println!("{message}");
16 }
17}
Sourcepub fn generage_text(&self) -> String
pub fn generage_text(&self) -> String
Examples found in repository?
examples/basic.rs (line 13)
3fn main() {
4 let sample_texts = ["Math is dumb", "Timo is cool"]
5 .iter()
6 .map(|&s| s.to_string())
7 .collect();
8
9 let mut model = MarkovTextModel::<4>::new();
10 model.add_sample_texts(&sample_texts);
11
12 for _ in 0..200 {
13 let message = model.generage_text();
14
15 println!("{message}");
16 }
17}
Trait Implementations§
Source§impl<const CONTEXT_LENGTH: usize> Clone for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> Clone for MarkovTextModel<CONTEXT_LENGTH>
Source§fn clone(&self) -> MarkovTextModel<CONTEXT_LENGTH>
fn clone(&self) -> MarkovTextModel<CONTEXT_LENGTH>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<const CONTEXT_LENGTH: usize> Debug for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> Debug for MarkovTextModel<CONTEXT_LENGTH>
Auto Trait Implementations§
impl<const CONTEXT_LENGTH: usize> Freeze for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> RefUnwindSafe for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> Send for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> Sync for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> Unpin for MarkovTextModel<CONTEXT_LENGTH>
impl<const CONTEXT_LENGTH: usize> UnwindSafe for MarkovTextModel<CONTEXT_LENGTH>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more