zenoxygen / bayespam

A simple bayesian spam classifier written in Rust.
https://crates.io/crates/bayespam
MIT License
13 stars 4 forks source link

Reader instead of File #4

Open Houski opened 3 months ago

Houski commented 3 months ago

Would it be possible (and a good idea?) to change the required File type to Reader here?

pub fn new_from_pre_trained(file: &mut File) -> Result<Self, io::Error> {

So something like this can be performed:

let faux_model_file = include_str!("./perform_contact_spam_filter_model.json");

 let classifier = Classifier::new_from_pre_trained(&mut std::io::Cursor::new(faux_model_file)).expect("Failed to load spam filter model");

Without the need to touch the file system?

It seems like it should take something more like a &str, and then the user is responsible for however that &str gets to the function.