WPL.Enforce.Matcher (WPL Validator v1.9.0)

Copy Markdown View Source

Fuzzy exercise-name matcher for the Pass-3 enforcement engine.

Ported from wpl-validator-ts/src/enforce/matcher.ts. Pure functions. Any change here is a change to the safety contract — add a conformance fixture with every behavioral change.

Summary

Functions

Returns true when extracted (an exercise name from the plan) collides with blacklisted (a forbid pattern from a personalization rule).

Normalize a free-text name into a lowercase, underscore-separated token.

Strip a trailing English plural 's' from a token.

Functions

collides(extracted, blacklisted)

@spec collides(String.t(), String.t()) :: boolean()

Returns true when extracted (an exercise name from the plan) collides with blacklisted (a forbid pattern from a personalization rule).

normalize(s)

@spec normalize(String.t()) :: String.t()

Normalize a free-text name into a lowercase, underscore-separated token.

stem_plural(token)

@spec stem_plural(String.t()) :: String.t()

Strip a trailing English plural 's' from a token.