feat: improved categorization helper to include common bigrams#455
Closed
feat: improved categorization helper to include common bigrams#455
Conversation
Closed
2 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #455 +/- ##
=======================================
Coverage 24.17% 24.17%
=======================================
Files 27 27
Lines 1580 1580
Branches 263 263
=======================================
Hits 382 382
Misses 1173 1173
Partials 25 25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
Author
|
@TimeToBuildBob Take over this in a new PR, add tests etc. |
TimeToBuildBob
added a commit
to TimeToBuildBob/aw-webui
that referenced
this pull request
Apr 14, 2026
…ort and tests Moves the common-phrase detection logic from CategoryBuilder.vue into a standalone src/util/categorization.ts module and adds 10 unit tests. Changes vs original PR ActivityWatch#455: - Extracts function to util module for testability - Uses Map<string, WordEntry> (consistent with existing CategoryBuilder code) - Filters bigram components against ignored_words and length <= 2 - Removes debug console.log statements - Full TypeScript types Closes ActivityWatch#455
Contributor
|
Done — took this over in #803. Changes from the original:
|
ErikBjare
pushed a commit
that referenced
this pull request
Apr 14, 2026
…ort and tests (#803) * feat(categorization): extract findCommonPhrases util with bigram support and tests Moves the common-phrase detection logic from CategoryBuilder.vue into a standalone src/util/categorization.ts module and adds 10 unit tests. Changes vs original PR #455: - Extracts function to util module for testability - Uses Map<string, WordEntry> (consistent with existing CategoryBuilder code) - Filters bigram components against ignored_words and length <= 2 - Removes debug console.log statements - Full TypeScript types Closes #455 * fix(categorization): snapshot word durations before bigram promotion loop Without this, promoting a bigram (e.g. 'Alpha Beta') reduces constituent word durations in-place. A later bigram that shares the middle word (e.g. 'Beta Gamma') then sees Beta.duration=0, so the check becomes 10/0 = Infinity > 0.5 and the weak bigram is incorrectly promoted. Fix: build an originalDurations snapshot before the Step 3 loop and use it for all threshold comparisons; mutations to entry.duration still happen (for accurate display) but no longer corrupt subsequent checks. Also adds a regression test that fails on the unfixed code. * fix(categorization): replace non-null assertions with explicit undefined guards * style(categorization): fix prettier line-length warning in guard clause
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Came up with this while thinking about the bug in ActivityWatch/activitywatch#905, with the help of ChatGPT: https://chat.openai.com/share/0c7588ee-b13b-41e3-b169-c1e587fcbb72
Ran a quick test while developing, but never actually tested it in the UI.