use std::{fs, path::Path}; use rand::{seq::SliceRandom, thread_rng}; pub fn load(path: impl AsRef, width: usize) -> Vec { let content = fs::read_to_string(path).expect("Can read file."); content .lines() .filter(|w| w.len() == width) .map(|l| l.to_string()) .collect() } pub fn francais(width: usize) -> Vec { let raw = include_str!("../data/francais.txt"); raw.lines() .filter(|w| w.len() == width) .map(|l| l.to_string()) .collect() } pub fn gutenberg(width: usize) -> Vec { let raw = include_str!("../data/gutenberg.txt"); let mut res = raw .lines() .filter(|w| w.len() == width) .map(|l| l.to_string()) .collect::>(); res.shuffle(&mut thread_rng()); res }