Skip to content

Commit

Permalink
feat: keep track of the number of words seen
Browse files Browse the repository at this point in the history
  • Loading branch information
BrewingWeasel committed Jul 16, 2024
1 parent 29af00f commit 9dd9799
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src-tauri/src/language_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,23 @@ pub async fn parse_text(
.expect("Language to have already been chosen");
let interpreter = load_spyglys(&mut state)?;

if state.language_parser.is_some() {
let words = if state.language_parser.is_some() {
log::trace!("Sending to stanza parser");
stanza_parser(sent, &mut state, language, &interpreter)
stanza_parser(sent, &mut state, language.clone(), &interpreter)
} else {
default_tokenizer(sent, language, &mut state, &interpreter)
}
default_tokenizer(sent, language.clone(), &mut state, &interpreter)
}?;
state
.to_save
.language_specific
.get_mut(&language)
.expect("language to have state")
.words_seen
.push((
chrono::Utc::now(),
words.iter().filter(|v| v.clickable).count(),
));
Ok(words)
}
#[derive(serde::Deserialize, Clone)]
struct StanzaToken {
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct LanguageSpecficToSave {
cached_defs: HashMap<String, Vec<SakinyjeResult<String>>>,
previous_file: Option<String>,
previous_amount: usize,
words_seen: Vec<(DateTime<Utc>, usize)>,
}

impl Default for SharedInfo {
Expand Down

0 comments on commit 9dd9799

Please sign in to comment.