How it works¶
text → recognizers (regex) → validators (checksum) → context scoring → dedup → threshold + allow list → results
The pipeline:
- Every applicable recognizer runs its regexes over the text.
- The engine scores a matched span at the pattern's base confidence; a
validator then either promotes it to
1.0(verified) or drops it (failed checksum). - Words around a match that support it raise its score; see context-aware scoring.
- Overlapping spans of the same entity type are de-duplicated (the enclosing/higher-scoring span wins). Different entity types never suppress each other.
- An optional score threshold and allow list filter what remains.
- Each surviving result carries the matched substring (
Result.Text).
Reading a Result¶
type Result struct {
EntityType string // e.g. entities.CreditCard
Start, End int // byte offsets: text[Start:End] == Text
Score float64
Text string
RecognizerName string
}
Offsets are byte indices, not runes, and this holds for model-backed results too, including multi-byte input. See Design & limits for what the scores do and do not mean.