Skip to content

refactor(web): new method - attemptTokenizedAlignment 🚂 #14364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

jahorton
Copy link
Contributor

Following from #14363, this method performs context alignment calculations that may be used to match forms of the context before and after an edit by aligning their tokens and validating any edits that may have occurred.

Note that no 'tracked context' states are manipulated or altered by this method - it solely calculates the alignment deltas needed to align the two contexts. Other methods may then take these values and determine the edits that occurred during the associated context transition as needed.

Note that the attemptTokenizedAlignment method is not integrated into the main codebase for the predictive-text worker at this time. That said, this method does integrate the isSubstitutionAlignable method introduced by #14363.

@keymanapp-test-bot skip

Following from #14363, this method performs context alignment calculations that may be
used to match forms of the context before and after an edit by aligning their tokens and
validating any edits that may have occurred.

Note that no 'tracked context' states are manipulated or altered by this method - it
solely calculates the alignment deltas needed to align the two contexts.  Other methods
may then take these values and determine the edits that occurred during the associated
context transition as needed.

Note that the `attemptTokenizedAlignment` method is not integrated into the main codebase
for the predictive-text worker at this time.  That said, this method _does_ integrate
the `isSubstitutionAlignable` method introduced by #14363.
@keymanapp-test-bot keymanapp-test-bot bot changed the title refactor(web): new method - attemptTokenizedAlignment refactor(web): new method - attemptTokenizedAlignment 🚂 Jul 15, 2025
@keymanapp-test-bot keymanapp-test-bot bot added this to the A19S7 milestone Jul 15, 2025
jahorton added a commit that referenced this pull request Jul 15, 2025
…dAlignment method

Following from #14364, this PR integrates the new method with the main predictive-text context-tracking code, significantly reworking the `attemptMatchContext` method in the process.  While further refactoring of the latter method is planned, this step allows us to verify that the new methods integrate properly with the main codebase in their current form.

This also comes with the benefit of simplifying `attemptMatchContext` _significantly_ - large parts of its code were refactored into `attemptTokenizedAlignment`, and the new logic patterns are generally more straightforward to parse and understand.
@keyman-server keyman-server modified the milestones: A19S7, A19S8 Jul 20, 2025
Copy link
Contributor

@ermshiperete ermshiperete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if(tailInsertLength > 0 && tailDeleteLength > 0) {
// Something's gone weird if this happens; that should appear as a substitution instead.
// Otherwise, we have a VERY niche edit scenario.
return {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to log this case?

Base automatically changed from feat/web/is-substitution-alignable to epic/autocorrect July 24, 2025 14:59
@jahorton jahorton merged commit 521aae9 into epic/autocorrect Jul 24, 2025
17 of 18 checks passed
@jahorton jahorton deleted the refactor/web/attempt-tokenized-alignment branch July 24, 2025 14:59
@github-project-automation github-project-automation bot moved this from Todo to Done in Keyman Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants