Added ? and ! to finishing characters
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
09ae96555c
commit
711d65424a
@ -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(); }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user