Skip to content

feat(web): adds finalizer quotient-node type for facilitating multi-word corrections 🚂#15855

Open
jahorton wants to merge 3 commits intofeat/web/search-space-node-propagationfrom
feat/web/quotient-node-finalizer
Open

feat(web): adds finalizer quotient-node type for facilitating multi-word corrections 🚂#15855
jahorton wants to merge 3 commits intofeat/web/search-space-node-propagationfrom
feat/web/quotient-node-finalizer

Conversation

@jahorton
Copy link
Copy Markdown
Contributor

@jahorton jahorton commented Apr 17, 2026

As noted in the description of #15818, when correcting multiple tokens together, we will want the ability to restrict some of them to use only corrections. To facilitate this, the new QuotientNodeFinalizer type allows us to penalize corrections that result in incomplete words, adding one "penalty unit" of cost for each additional codepoint needed to result in an actually-completed word.

Build-bot: skip build:web
Test-bot: skip

@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot Bot commented Apr 17, 2026

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

  • Web
    • KeymanWeb Test Home - build : all tests passed (no artifacts on BuildLevel "build")

@keymanapp-test-bot keymanapp-test-bot Bot changed the title feat(web): adds finalizer quotient-node type for facilitating multi-word corrections feat(web): adds finalizer quotient-node type for facilitating multi-word corrections 🚂 Apr 17, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S27 milestone Apr 17, 2026
@jahorton jahorton force-pushed the feat/web/quotient-node-finalizer branch 2 times, most recently from cf60a5e to 4c102d4 Compare April 17, 2026 21:56
Comment on lines +440 to +462
const tokenizations = [fixture.theref, fixture.the_ef];
const correctors = tokenizations.map((t) => new TokenizationCorrector(t, t.tokens.length, fixture.filter));

let haveSeenSingleTokenCorrection = false;
let haveSeenThreeTokenCorrection = false;
for await(let phraseMatch of getBestMatches<
ReadonlyArray<TokenResult>,
TokenizationResultMapping,
TokenizationCorrector
>(correctors, buildTestTimer())) {

if(phraseMatch.matchedResult.length == 1) {
if(!haveSeenSingleTokenCorrection) {
assert.sameOrderedMembers(phraseMatch.matchedResult.map((t) => t.matchString), ['theref' /* -ore */]);
}

haveSeenSingleTokenCorrection = true;
} else if(phraseMatch.matchedResult.length == 3) {
if(!haveSeenThreeTokenCorrection) {
assert.sameOrderedMembers(phraseMatch.matchedResult.map((t) => t.matchString), ['the', ' ', 'ef' /* -fort */]);
}
haveSeenThreeTokenCorrection = true;
}
Copy link
Copy Markdown
Contributor Author

@jahorton jahorton Apr 17, 2026

Choose a reason for hiding this comment

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

Ooh, shiny new unit test - one that supports "correcting away" the whitespace! No predictions yet, granted, but this is a major step in the right direction.

(The whitespace is higher probability, for this test, than the r that replaces it.)

@jahorton jahorton force-pushed the feat/web/search-space-node-propagation branch from 57d836b to bde82ad Compare April 22, 2026 17:54
@jahorton jahorton force-pushed the feat/web/quotient-node-finalizer branch from 561ad80 to 18ef0a4 Compare April 22, 2026 18:13
@jahorton jahorton force-pushed the feat/web/quotient-node-finalizer branch from 18ef0a4 to 2a5f907 Compare April 22, 2026 18:45
@jahorton jahorton requested a review from ermshiperete April 24, 2026 14:30
@jahorton jahorton marked this pull request as ready for review April 24, 2026 14:30
@keyman-server keyman-server modified the milestones: A19S27, A19S28 Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants