izzilis/src/generator.rs

31 lines
796 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> {
Ok(self
.model
.get_sample()?
.replace(SAMPLE_SAMPLE_LINE, "")
.split(SAMPLE_SPLIT_WORD)
.into_iter()
.map(|elem| elem.trim().to_owned())
.collect::<Vec<_>>())
}
}