diff options
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/state.rs b/src/state.rs index 195d5cf..47998f3 100644 --- a/src/state.rs +++ b/src/state.rs @@ -4,19 +4,24 @@ use directories::ProjectDirs; use expanduser::expanduser; use serde::{Deserialize, Serialize}; -use crate::{albums, config::Config, learner::Learner, trajectory::Trajectory}; +use crate::{albums, config::Config, intuition::Intuition, trajectory::Trajectory}; fn default_state_path() -> String { let name = "mood.json.zstd"; ProjectDirs::from("qualifier", "organisation", "mood") - .and_then(|pd| pd.config_dir().join(name).to_str().map(std::string::ToString::to_string)) + .and_then(|pd| { + pd.config_dir() + .join(name) + .to_str() + .map(std::string::ToString::to_string) + }) .unwrap_or(format!("~/.config/mood/{name}")) } #[derive(Serialize, Deserialize, Default)] pub struct State { trajectory: Trajectory, - learner: Learner, + intuition: Intuition, } impl State { @@ -25,16 +30,15 @@ impl State { if albums.is_empty() { println!("Found no albums in {}", config.music_root); return None; - } else { - let l = albums.len(); - println!("Found {} album{}", l, if l > 1 { "s" } else { "" }); } + let l = albums.len(); + println!("Found {} album{}", l, if l > 1 { "s" } else { "" }); let learning = self.trajectory.step(config.skip_window_secs); if let Some(ref learning) = learning { - self.learner.learn(learning); + self.intuition.learn(learning); } - if let Some((new_album, prob)) = self.learner.sample( + if let Some((new_album, prob)) = self.intuition.sample( self.trajectory.slice(), &learning.as_ref().into(), &albums, @@ -77,8 +81,8 @@ impl State { } impl State { - pub fn dump_learner(&self) -> Result<String, String> { - serde_json::to_string_pretty(&self.learner).map_err(|e| e.to_string()) + pub fn dump_intuition(&self) -> Result<String, String> { + serde_json::to_string_pretty(&self.intuition).map_err(|e| e.to_string()) } pub fn dump_trajectory(&self) -> Result<String, String> { |
