Skip to content

metrics(exact_match): docstring promises whitespace normalization the comparison doesn't do #225

Description

@Nitjsefnie

Small one from the bug-hunt. ExactMatch's class docstring says "Comparison is case-insensitive and whitespace-normalized", but the implementation only does .strip().lower() — internal whitespace is not collapsed, so answer="hello world" vs ground_truth="hello world" scores 0.0 despite the documented contract.

Two ways to close it, maintainer's call:

  1. Make the code match the docstring: normalize with " ".join(text.lower().split()) — the exact pattern metrics/retrieval/_normalize.py already uses; or
  2. Make the docstring match the code ("leading/trailing whitespace stripped").

Given the retrieval normalizer precedent I'd lean (1), and it's a two-line change + a test — happy to PR whichever you prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions