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};
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(); }
}