Skip to content

A figure followed by 余 or 多 is a bound and not a value, so "5000余万元" is no value instead of 5000 - #1441

Open
rudycelekli wants to merge 1 commit into
deeplethe:devfrom
rudycelekli:extract-yu-duo-bound
Open

rudycelekli wants to merge 1 commit into
deeplethe:devfrom
rudycelekli:extract-yu-duo-bound

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Why

strip_approx documents the rule: 约 / 左右 only say a number is approximate, so the number stays; 超过 / 余 state a bound, and "把界当成值就是一条原文没说的断言". 超过 sits in front of the number and is never stripped, so "超过一千人" is no value. 余 and its everyday twin 多 sit after the number, between it and the magnitude: "5000余万元" (more than 50 million yuan), "300多人". scan_quantity stops the number at 余, cannot read "余万元" as a magnitude, and the lenient path keeps the bare 5000 with "余万元" as a unit word:

  • "5000余万元" under a number attribute (no unit, or 元) is stored as 5000: four orders of magnitude off, and a lower bound recorded as the value.
  • "5000多万元" under 万元 is stored as 5000, and "300多人" under 人 as 300, both bounds recorded as exact counts.

What changes

If the text right after the number starts with 余 or 多, scan_quantity returns no quantity, the same outcome "超过一千人" already has. Plain figures ("300人", "5000万元") are unchanged.

How it was checked

  • A new test, a_figure_followed_by_yu_or_duo_is_a_bound_not_a_value, covers "5000余万元" with no unit and under 元, "5000多万元" under 万元, "300多人" under 人, and "300人" still reading 300.
  • With the fix reverted the test fails: left: Some(Number(5000.0)) right: None.
  • cargo test -p utopia-extract --lib: 113 passed.
  • cargo fmt -p utopia-extract --check and cargo clippy -p utopia-extract --all-targets -- -D warnings pass.

Before review

  • Every commit is signed off (git commit -s)
  • cargo fmt --all --check, cargo clippy and cargo test pass for the touched crate

…is no value instead of 5000

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant