diff --git a/src/main.rs b/src/main.rs index 80fc9df..2e5371f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{fs, env, collections::{HashMap, HashSet}}; +use std::{fs, env, collections::{HashMap, HashSet}, time::Instant}; use rand::{seq::SliceRandom, prelude::ThreadRng}; fn read_input(path: &str) -> String { @@ -34,8 +34,10 @@ fn main() { let mut rng = &mut rand::thread_rng(); let mut sen = vec![]; loop { - while !sen.last().unwrap_or(&"".to_string()).ends_with(".") { - sen.push(get_random_next_from(sen.last().unwrap_or(&"".to_string()), &vec_in, &mut rng)); + let mut last = "".to_string(); + while !(last.ends_with(".") || last.ends_with("?") || last.ends_with("!")) { + last = get_random_next_from(&last, &vec_in, &mut rng); + sen.push(last.clone()); } if !input.contains(sen.join(" ").as_str()) { break; } else { sen.clear(); } }