Repository navigation
A full-width percent sign is a percentage, so a "12.5%" object becomes a value instead of an entity named 12.5% - #1440
Open
rudycelekli wants to merge 1 commit into
Conversation
…s a value instead of an entity named 12.5% Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
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
values_are_not_thingsmoves an object that is really a value ("5000万元", "52%", "2015年3月12日") back into the value slot, so the open extraction does not create an entity named after a figure. It decides withliteral_object, which asksscan_quantitywhether the whole name is one quantity.scan_quantityonly recognizes the ASCII percent sign. Chinese typesetting very often uses the full-width one: "增长12.5%", "毛利率为38.6%". For "12.5%" the scan leaves%as an unknown trailing word, the strict check rejects it, andliteral_objectsays it is not a value.So when the model writes "12.5%" as the object (the case this function exists for), it stays an object. The statement becomes a relation to an entity called "12.5%" instead of a percentage, and it can never bind to the numeric attribute it states.
What changes
scan_quantitystrips either%or%as the percent suffix. A full-width percentage now reads exactly like the ASCII one, with the unit%. Nothing else in the scan changes.How it was checked
a_full_width_percent_sign_is_a_percentage, checks thatliteral_object("12.5%", true)is true, thatparse_quantity("12.5%")is(12.5, "%"), that "-3.2 %" reads like "-3.2%", and that the value under a%unit is still 12.5.literal_object("12.5%", true).cargo test -p utopia-extract --lib: 113 passed.cargo fmt -p utopia-extract --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