diff --git a/evaluations/evaluations/numbers.py b/evaluations/evaluations/numbers.py index 0bf3c8ed..82618ccb 100644 --- a/evaluations/evaluations/numbers.py +++ b/evaluations/evaluations/numbers.py @@ -42,6 +42,7 @@ def extract_numbers(text: str) -> list[float]: parenthesised negatives. Numbers qualified by a scale word ("1.2 million") contribute both the raw and the scaled value, so either phrasing can match. """ + text = text.replace("−", "-") # normalize the typographic minus sign numbers: list[float] = [] for token in _NUMBER_RE.findall(text): value = _to_float(token) diff --git a/evaluations/tests/test_numbers.py b/evaluations/tests/test_numbers.py index 0cc937c4..5dfaac92 100644 --- a/evaluations/tests/test_numbers.py +++ b/evaluations/tests/test_numbers.py @@ -14,6 +14,9 @@ class TestExtractNumbers: def test_parenthesised_negative(self) -> None: assert extract_numbers("loss of (123)") == [-123.0] + def test_unicode_minus(self) -> None: + assert extract_numbers("a change of −1.9 million") == [-1.9, -1.9e6] + def test_scale_word_adds_scaled_and_raw(self) -> None: numbers = extract_numbers("revenue of 1.2 billion") assert 1.2 in numbers