feat(meta): add DataPointMention for quantitative data points#679
Open
ceberam wants to merge 1 commit into
Open
feat(meta): add DataPointMention for quantitative data points#679ceberam wants to merge 1 commit into
ceberam wants to merge 1 commit into
Conversation
Contributor
|
✅ DCO Check Passed Thanks @ceberam, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ed in text Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
ceberam
force-pushed
the
dev/entity-data-point
branch
from
July 9, 2026 13:50
6087c26 to
09aee82
Compare
| """Valid values for DataPointMention.scale. Each value maps to a known numeric multiplier.""" | ||
|
|
||
|
|
||
| class DataPointMention(EntityMention): |
Member
There was a problem hiding this comment.
if everything is optional, can we potentially have completely empty fields?
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.
Summary
Extends the document metadata model with first-class support for quantitative
data point mentions — values such as
"$4B","3.0%", or"between 10 and 20 °C"that appear in running text and carry machine-readable numeric meaning.What's new
DataPointMentionA new subclass of
EntityMentionthat adds a structured numeric breakdownalongside the inherited surface-form fields (
text,orig,label,charspan):valuefloatunitstr"USD","°C","%")scaleDataPointScale"billion","k", …)normalized_valuefloatvalue * scale_factorin base unitsrange_endfloatdisplay_dpint"3%"→ 0,"3.0%"→ 1)precisionDataPointPrecision"exact","approximate","range_low", …)directionDataPointDirection"increase","decrease","neutral")Two helper members are provided:
scale_factor— property returning the numeric multiplier for the storedscalevaluecompute_normalized_value()— derivesvalue * scale_factoron demand, useful when fields are set after constructionPublic
Literaltype aliasesDataPointScale,DataPointPrecision, andDataPointDirectionare exportedas public
Literaltype aliases. They serve as the field annotations (givingPydantic automatic validation and IDE completion) and as a documented API
surface consumers can inspect at runtime via
typing.get_args(...).Integration with
EntitiesMetaFieldDataPointMentionobjects are stored in the existingentitiesmetadatafield — no new top-level field is introduced.
EntitiesMetaField.mentionsis widened to
list[Union[DataPointMention, EntityMention]]so that plainnamed entities and data points can coexist in the same list and survive
JSON roundtrips with full type fidelity.
Design notes
DataPointMentionis a non-breaking extension ofEntityMention: allnumeric fields are optional, so existing entity mentions are unaffected.
scalefield is a closedLiteralmatching the keys of the internalscale_factormap — storing an unrecognised scale string is rejected atconstruction time rather than silently making
compute_normalized_value()return
None.display_dpandprecisionare orthogonal: the former captures how manydecimal places the author wrote, the latter captures their epistemic hedge
(
"roughly 3%"→precision="approximate",display_dp=0).