| import pytest |
|
|
| from math_verify import StringExtractionConfig, parse |
|
|
|
|
| @pytest.mark.parametrize( |
| "pred,expected,config", |
| [ |
| |
| ("The answer is A.", ["A", "A"], StringExtractionConfig(lowercase=False)), |
| |
| ("The answer is A.", ["a", "A"], StringExtractionConfig(lowercase=True)), |
| |
| ("Final answer is B", ["b", "B"], StringExtractionConfig()), |
| |
| ("No valid answer here", [], StringExtractionConfig()), |
| |
| ("A. Because B is not valid", ["a", "A"], StringExtractionConfig()), |
| |
| |
| ("The answer is U.", ["u", "U"], StringExtractionConfig(strings=("U",))), |
| |
| ("Because B is valid", ["b", "B"], StringExtractionConfig()), |
| ], |
| ) |
| def test_string_extraction(pred, expected, config): |
| assert parse(pred, [config]) == expected |
|
|