Skip to content

Context in recognizer YAML is ignored when scoring matches #1696

@yuvalyaron

Description

@yuvalyaron

Describe the bug
When using a custom recognizer defined in YAML with a context field, the context words are ignored in scoring. The match score remains at the base pattern score instead of being boosted by the context.

To Reproduce

  1. Create a custom recognizer YAML:
- name: "Date of Birth Recognizer"
  type: custom
  supported_languages:
    - en
  patterns:
    - name: "DOB without slashes"
      regex: "(\b(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\b)"
      score: 0.8
  context:
    - DOB
  supported_entity: "DATE_TIME"
  1. Load it into Presidio and run:
res = analyzer.analyze(
    text="DOB: 19571012",
    language="en",
    return_decision_process=True
)
  1. Observe the match score.
    It's 0.8, instead of 1.

Expected behavior
The context DOB should boost the score from 0.8 to 1.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions