Skip to content

Unenumerated dollar codes (A$, C$, R$, S$) are scored as US dollars #32

Description

@jeremiahsay

$ in the currency-prefix matcher has no left boundary, so any unlisted currency code ending in $ is read as US dollars.

Baseline: this needs #30, which introduces the prefix matcher. On main today all four cases below are unscoreable, because the currency never reaches reconcile at all — that is the #23 bug, not a safeguard.

python3 -c "
import score
for t in ['About A\$50 per tCO2e.', 'About C\$80 per tCO2e.',
          'About R\$100 per tCO2e.', 'About S\$25 per tCO2e.']:
    print(t, '->', score.best_value(t, 'USD/tCO2e'))
"
About A$50 per tCO2e.   -> (50.0, '$ per tCO2e.', None)
About C$80 per tCO2e.   -> (80.0, '$ per tCO2e.', None)
About R$100 per tCO2e.  -> (100.0, '$ per tCO2e.', None)
About S$25 per tCO2e.   -> (25.0, '$ per tCO2e.', None)

NT$ is handled because it was enumerated after it turned up in the answers. The others are not, so R$100 — about USD 18 — scores as 100 against a US-dollar truth. That is a ~5x error presented as a confident answer, which is worse than the unscoreable it would have been before the prefix matcher existed.

No live hits today

The corpus does contain A$ and S$ (reporting.aasb_s2.group1.applicability, reporting.aasb_s2.group3.applicability, reporting.sgx_acra.listed_non_sti_ge_1bn), but every one of those questions has a date truth, so the answers are unscoreable for an unrelated reason. Nothing in results/ is currently mis-scored by this. It is latent, not live.

Why it is worth fixing anyway

Enumerating known codes means the failure mode is silent and the default is wrong: a currency nobody listed becomes USD rather than becoming unscoreable. The holdout split is pre-registered and has never been scored, so the first time this bites may well be on the numbers that matter most.

Suggested fix

Require that the $ alternative is not preceded by a letter, and treat a <letters>$ form that is not a known code as an unknown currency — which, after #31, means reconcile refuses it rather than assuming USD.

Worth a test per code, in the style of verify/test_currency_mismatch.py.

Found while reviewing #30.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions