fix(#74): wire Transaction.confidence_score via ExtractionScoringConfig#77
Merged
fix(#74): wire Transaction.confidence_score via ExtractionScoringConfig#77
Conversation
Introduces ExtractionScoringConfig (injectable frozen dataclass) holding penalty weights for extraction anomalies, following the ScoringConfig pattern established in PR #36. RowPostProcessor now applies penalties and stamps confidence_score on each transaction row dict: - DATE_PROPAGATED: -0.1 (date inferred from prior row or filename) - MISSING_BALANCE: -0.2 (balance field absent or empty) Score is clamped to [0.0, 1.0]. Rows with no anomalies keep 1.0. PDFTableExtractor accepts an optional scoring_config and threads it through to RowPostProcessor; defaults to ExtractionScoringConfig.default(). Adds CODE_MISSING_BALANCE warning code to extraction_warning.py. Exports ExtractionScoringConfig from domain/models/__init__.py. 19 new tests cover: full-confidence, date-propagated, missing-balance, both penalties, clamping, injectable config, and non-transaction rows.
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
Closes #74.
Transaction.confidence_scorewas declared but always1.0— no pipeline code ever set it. This PR wires real values by detecting two extraction anomalies inRowPostProcessorand stamping the computed score onto each transaction row dict before it reachesTransaction.from_dict().Changes
domain/models/extraction_scoring_config.py—ExtractionScoringConfigfrozen dataclass with injectable penalty weights, following theScoringConfigpattern from PR feat(#32): make ScoringConfig injectable in TemplateDetector #36CODE_MISSING_BALANCEwarning code added toextraction_warning.pyRowPostProcessoraccepts optionalExtractionScoringConfig; applies penalties and stampsconfidence_scoreon transaction row dicts:DATE_PROPAGATED: −0.1 (date inferred from prior row or filename)MISSING_BALANCE: −0.2 (balance field absent or empty)[0.0, 1.0]PDFTableExtractoraccepts optionalscoring_configand threads it toRowPostProcessordomain/models/__init__.pyexportsExtractionScoringConfigtests/extraction/test_confidence_scoring.py— 19 tests covering all signal combinationsType
Testing
make docker-integrationpassed locally (touchespackages/parser-core/)Checklist