Repository navigation
A currency code written against its number is read, so "HK$300 million" is 300 million instead of no value - #1423
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
…n" is 300 million instead of no value Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
WaylandYang
requested changes
Oct 25, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
The new branch also runs in the strict scan, so a named "USD1" or "euro2024" now counts as a value and its node is lost. Please limit it to the lenient scan, as #1422 does, and accept a - after the code so "HK$(300) million" works once #1422 lands. It conflicts with #1416 and #1422; please rebase after them.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
currency_unitknowsHK$,US$,RMB,USDand the other multi-character currencies.scan_quantityonly finds them in two places: as the very first character ($,€,¥), or as a word followed by a space (USD 30).Hong Kong and China filings usually write the code directly against the number:
HK$300 million,US$5 billion,RMB5000万. For those, no currency is found and the scan stops at the first letter. The number attribute is then dropped.normalize_attr_value("number", "HK$300 million")isNone, and so isattribute_valueunder万元forRMB5000万.What changes
If neither existing check finds a currency, the text before the first digit is looked up in the same
currency_unittable.HK$,US$,RMBandUSDare found there, and the scan continues from the number. Text that is not in the table, like theAinA320, is not a currency, so a model number stays a name.How it was checked
A new test,
a_currency_code_written_against_the_number_is_read:HK$300 millionis300000000.US$5 billionis5000000000.RMB5000万under万元is5000.US$5000万under万元is still refused as a currency mismatch.A320is still not a literal.Results:
cargo test -p utopia-extract --lib: 112 passed.left: None,right: Some(Number(300000000.0)).cargo fmt --all --checkandcargo clippy -p utopia-extract --all-targets -- -D warningspass.Before review
git commit -s)cargo fmt --all --check,cargo clippyandcargo testpass for the touched crate