Explain why a pattern matched
Explain why a pattern matched
See, for a match, the kind of every token it spans, what each checked kind passed to be that kind, the value every axis the pattern read had there, and which rung of the scan answered (explanations).
A checked kind
A card number is a card only where it passes the Luhn check, and the explanation says so:
$ trex scan '\{card}' --explain --text 'pay 4111 1111 1111 1111 now'
[4..23] "4111 1111 1111 1111"
tokens: creditcard "4111 1111 1111 1111"
guard: creditcard: 13 to 19 digits in an issuer's grouping, passing the Luhn check
route: a route, not the engine
A threshold read from the input
A relative predicate compares with a baseline the input supplies, and the explanation gives the value and the baseline it was compared with:
$ trex scan '\N{>+1}' --explain --text 'sizes 12 15 9 4000'
[14..18] "4000"
tokens: number "4000"
magnitude: 3.60 "4000"
baseline: window: mean 1.38, spread 0.55, over 4 "4000"
route: the set engine over a whole lex
--format writes any one reading of an explanation into a line of your own:
${@kind}, ${@guard}, ${@route}, and ${@magnitude}, ${@spectral.entropy} and the other
axes the pattern read (report templates).