change(web): address other concerns from PR review

This commit is contained in:
Joshua Horton 2026-05-05 12:25:35 -05:00
parent 3c03a53e64
commit 91b097f7a4
3 changed files with 7 additions and 6 deletions

View file

@ -236,6 +236,7 @@ export abstract class SearchQuotientNode implements CorrectionSearchable<SearchN
* Log the results of a processed node and queue it within all subscribed
* processor nodes for construction of deeper search paths.
* @param result A search result whose path terminates at this SearchQuotientNode.
* @returns true if the entry is new or of better cost; else, false.
*/
protected saveResult(result: TokenResultMapping): boolean {
const priorMatch = this.returnedValues[result.matchString];

View file

@ -431,9 +431,9 @@ export abstract class SearchQuotientSpur extends SearchQuotientNode {
const result = new TokenResultMapping(this, currentNode);
if(currentNode.spaceId == this.spaceId) {
// Verify that we don't already have a better-cost result for the
// correction already.
const isUnhandled = this.saveResult(result);
if(!isUnhandled) {
// correction.
const isNewOptimalEntry = this.saveResult(result);
if(!isNewOptimalEntry) {
// Not a better cost, so reject it and move on to the next potential result.
return this.handleNextNode();
}

View file

@ -214,13 +214,13 @@ describe('Correction Searching', () => {
const distrib_o2 = [
{ sample: { insert: 'o', deleteLeft: 0, id: 12 }, p: 0.3 }
];
const distrib_i2 = [
const distrib_r2 = [
{ sample: { insert: 'r', deleteLeft: 0, id: 12 }, p: 0.2 }
];
const thPath = new LegacyQuotientSpur(tPath, distrib_h2, distrib_h2[0]);
const toPath = new LegacyQuotientSpur(tPath, distrib_o2, thPath.inputSource);
const trPath = new LegacyQuotientSpur(tPath, distrib_i2, thPath.inputSource);
const trPath = new LegacyQuotientSpur(tPath, distrib_r2, thPath.inputSource);
const twoCharCluster = new SearchQuotientCluster([thPath, toPath, trPath]);
@ -294,7 +294,7 @@ describe('Correction Searching', () => {
// Passes through t and r, then diverges.
const gen_trvr = getBestTokenMatches([paths.trvrPath], buildTestTimer());
// Do we get further expected results if we keep querying?
// Verify that each divergent QuotientNode has further expected results if we keep querying.
assert.equal(((await gen_trvr.next()).value as TokenResultMapping).matchString, 'tre');
assert.equal(((await gen_trvr.next()).value as TokenResultMapping).matchString, 'tro');
assert.equal(((await gen_trvr.next()).value as TokenResultMapping).matchString, 'tra');