izzilis/src/generator.rs

33 lines
933 B
Rust

use std::io;
use crate::model;
const SAMPLE_SPLIT_WORD: &str = "<|endoftext|>";
const SAMPLE_SAMPLE_LINE: &str =
"======================================== SAMPLE 1 ========================================";
pub struct Generator<T: model::SampleModel> {
model: T,
}
// Why did this fucking shit take so long to sort out??
impl<T> Generator<T>
where
T: model::SampleModel,
{
pub fn new(model: T) -> Generator<T> {
Self { model }
}
pub fn generate_sample_lines(&self) -> Result<Vec<String>, io::Error> {
let unwashed_sample = self.model.get_sample()?;
// Cursed, I just wanted a Select
let mut washed_sample: Vec<String> = Vec::new();
unwashed_sample
.replace(SAMPLE_SAMPLE_LINE, "")
.split(SAMPLE_SPLIT_WORD)
.into_iter()
.for_each(|elem| washed_sample.push(elem.trim().to_string()));
Ok(washed_sample)
}
}