Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

NormalizerMatch

Defined in: packages/engine/src/normalizer/NormalizerRule.ts:80

Result of a successful rule match attempt against the token stream.

When a NormalizerRule.match function finds a pattern at the current position, it returns a NormalizerMatch describing how many tokens to consume and what to replace them with.

// The phrase "to the power of" (5 tokens) becomes a single CARET token
const match: NormalizerMatch = {
consumed: 5,
replacement: [caretToken],
};
consumed: number;

Defined in: packages/engine/src/normalizer/NormalizerRule.ts:85

Number of tokens consumed from the stream at the match position. Must be ≥ 1, a match always advances the cursor.


replacement: Token[];

Defined in: packages/engine/src/normalizer/NormalizerRule.ts:92

Replacement tokens to insert at the match position. May be empty (deletion), a single token (fusion), or multiple tokens (expansion/splitting).


optional ruleName?: string;

Defined in: packages/engine/src/normalizer/NormalizerRule.ts:100

Human-readable rule name for diagnostic fusion tracking. When set, the normalizer uses this instead of the rule’s name in TokenFusion records. Used by PhraseTrie to report which specific phrase matched (e.g., “phrase:to the power of”).