Skip to content

A typeset minus sign reads as negative, so "−3.2%" becomes -3.2 instead of no value - #1416

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
rudycelekli:extract-unicode-minus
Oct 25, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
rudycelekli:extract-unicode-minus

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Why

Typeset text writes negative numbers with the minus sign U+2212 (−), not the hyphen-minus -. Wikipedia's style requires it, and typeset PDFs and LaTeX output emit it. A model that copies a figure from such a passage into a number attribute writes "−3.2%". scan_quantity reads only [-+0-9.,_] as number characters, so the number part is empty and nothing parses.

normalize_attr_value and attribute_value both return None. The statement keeps no typed value, and a fall in revenue or margin never reaches the typed graph.

What changes

The number scan in scan_quantity also accepts − and reads it as - before parsing. Both readers, with and without a declared unit, go through this scan. No other character is added.

How it was checked

Three assertions in a_number_attribute_takes_a_written_quantity:

  • normalize_attr_value("number", "−3.2%") is -3.2.
  • normalize_attr_value("number", "−1,250") is -1250.
  • attribute_value("number", Some("万元"), "−2.3亿元") is -23000.

Results:

  • cargo test -p utopia-extract --lib: 111 passed.
  • With the fix reverted, that test fails with left: None, right: Some(Number(-3.2)).
  • cargo fmt --all --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

…ad of no value

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, merging. It overlaps #1423 in scan_quantity, so that one will need a rebase.

@WaylandYang
WaylandYang merged commit 22d4ae9 into deeplethe:dev Oct 25, 2026
6 checks passed
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.

2 participants