Skip to content

Commit c02de14

Browse files
committed
Merge branch 'refactor/web/correction-heuristic-and-thresholding' into refactor/web/relocate-search-space
2 parents 4940caa + 574caeb commit c02de14

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

web/src/engine/predictive-text/worker-thread/src/main/correction/context-token.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,15 @@ export class ContextToken {
124124
rawText ||= '';
125125

126126
// Supports the old pathway for: updateWithBackspace(tokenText: string, transformId: number)
127-
const rawTransformDistributions: Distribution<Transform>[] = textToCharTransforms(rawText).map(function(transform) {
128-
return [{sample: transform, p: 1.0}];
129-
});
130-
rawTransformDistributions.forEach((entry) => {
127+
// Build a token that represents the current text with no ambiguity - probability at max (1.0)
128+
const BASE_PROBABILITY = 1;
129+
textToCharTransforms(rawText).forEach((transform) => {
131130
this._inputRange.push({
132-
trueTransform: entry[0].sample,
131+
trueTransform: transform,
133132
inputStartIndex: 0,
134-
bestProbFromSet: 1
133+
bestProbFromSet: BASE_PROBABILITY
135134
});
136-
this.searchSpace.addInput(entry, 1);
135+
this.searchSpace.addInput([{sample: transform, p: BASE_PROBABILITY}], 1);
137136
});
138137
}
139138
}

web/src/engine/predictive-text/worker-thread/src/main/correction/context-tokenization.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ export class ContextTokenization {
499499
* the transition.
500500
* @param bestProbFromSet The probability of the single most likely input
501501
* transform in the overall transformDistribution associated with the
502-
* keystroke triggering theh transition. It need not be represented by the
502+
* keystroke triggering the transition. It need not be represented by the
503503
* pendingTokenization to be built.
504504
* @returns
505505
*/
@@ -586,7 +586,7 @@ export class ContextTokenization {
586586
if(affectedToken.inputRange.length == 0 && distribution[0].sample.deleteLeft != 0) {
587587
distribution = distribution.map((mass) => ({sample: { ...mass.sample, deleteLeft: 0 }, p: mass.p }));
588588
}
589-
affectedToken.addInput({trueTransform: sourceInput, inputStartIndex: appliedLength, bestProbFromSet: bestProbFromSet}, distribution);
589+
affectedToken.addInput({trueTransform: sourceInput, inputStartIndex: appliedLength, bestProbFromSet}, distribution);
590590
appliedLength += KMWString.length(distribution[0].sample.insert);
591591

592592
const tokenize = determineModelTokenizer(lexicalModel);

0 commit comments

Comments
 (0)