Added ? and ! to finishing characters

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2022-02-03 15:13:30 +01:00
parent 09ae96555c
commit 711d65424a
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283

View File

@ -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}; use rand::{seq::SliceRandom, prelude::ThreadRng};
fn read_input(path: &str) -> String { fn read_input(path: &str) -> String {
@ -34,8 +34,10 @@ fn main() {
let mut rng = &mut rand::thread_rng(); let mut rng = &mut rand::thread_rng();
let mut sen = vec![]; let mut sen = vec![];
loop { loop {
while !sen.last().unwrap_or(&"".to_string()).ends_with(".") { let mut last = "".to_string();
sen.push(get_random_next_from(sen.last().unwrap_or(&"".to_string()), &vec_in, &mut rng)); 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(); } if !input.contains(sen.join(" ").as_str()) { break; } else { sen.clear(); }
} }