Files
docs/khata-app/lib/pipelines/extraction/pdf/impl/index.html

4564 lines
134 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="../../../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.23">
<title>Impl - Khata App — Library Reference</title>
<link rel="stylesheet" href="../../../../assets/stylesheets/main.84d31ad4.min.css">
<link rel="stylesheet" href="../../../../assets/stylesheets/palette.06af60db.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,300i,400,400i,700,700i%7CJetBrains+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Inter";--md-code-font:"JetBrains Mono"}</style>
<link rel="stylesheet" href="../../../../assets/_mkdocstrings.css">
<link rel="stylesheet" href="https://unpkg.com/dracula-prism/dist/css/dracula-prism.css">
<script>__md_scope=new URL("../../../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="slate" data-md-color-primary="deep-purple" data-md-color-accent="cyan">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#impl" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="../../../.." title="Khata App — Library Reference" class="md-header__button md-logo" aria-label="Khata App — Library Reference" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4 1.79-4 4-4 4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4 1.5 0 2.87.27 4 .72M24 20H13V3h11zm-8-8.5a2.5 2.5 0 0 1 5 0 2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2z"/></svg>
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
Khata App — Library Reference
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Impl
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="deep-purple" data-md-color-accent="cyan" aria-hidden="true" type="radio" name="__palette" id="__palette_0">
</form>
<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<a href="javascript:void(0)" class="md-search__icon md-icon" title="Share" aria-label="Share" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg>
</a>
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
</button>
</nav>
<div class="md-search__suggest" data-md-component="search-suggest"></div>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../../../.." title="Khata App — Library Reference" class="md-nav__button md-logo" aria-label="Khata App — Library Reference" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4 1.79-4 4-4 4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4 1.5 0 2.87.27 4 .72M24 20H13V3h11zm-8-8.5a2.5 2.5 0 0 1 5 0 2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2z"/></svg>
</a>
Khata App — Library Reference
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../.." class="md-nav__link">
<span class="md-ellipsis">
Home
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_2" >
<div class="md-nav__link md-nav__container">
<a href="../../../../domain/" class="md-nav__link ">
<span class="md-ellipsis">
Domain
</span>
</a>
<label class="md-nav__link " for="__nav_2" id="__nav_2_label" tabindex="">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Domain
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../../domain/enrichment/" class="md-nav__link">
<span class="md-ellipsis">
Enrichment
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../../domain/fetch_pipeline/" class="md-nav__link">
<span class="md-ellipsis">
Fetch Pipeline
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../../domain/fetch_request/" class="md-nav__link">
<span class="md-ellipsis">
Fetch Request
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_3" >
<div class="md-nav__link md-nav__container">
<a href="../../../../infra/" class="md-nav__link ">
<span class="md-ellipsis">
Infra
</span>
</a>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Infra
</label>
<ul class="md-nav__list" data-md-scrollfix>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_4" >
<div class="md-nav__link md-nav__container">
<a href="../../../../interfaces/" class="md-nav__link ">
<span class="md-ellipsis">
Interfaces
</span>
</a>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
Interfaces
</label>
<ul class="md-nav__list" data-md-scrollfix>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_5" >
<div class="md-nav__link md-nav__container">
<a href="../../../" class="md-nav__link ">
<span class="md-ellipsis">
Pipelines
</span>
</a>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_5">
<span class="md-nav__icon md-icon"></span>
Pipelines
</label>
<ul class="md-nav__list" data-md-scrollfix>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl" class="md-nav__link">
<span class="md-ellipsis">
impl
</span>
</a>
<nav class="md-nav" aria-label="impl">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl--summary" class="md-nav__link">
<span class="md-ellipsis">
Summary
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl-classes" class="md-nav__link">
<span class="md-ellipsis">
Classes
</span>
</a>
<nav class="md-nav" aria-label="Classes">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmbiguityPort" class="md-nav__link">
<span class="md-ellipsis">
ImplAmbiguityPort
</span>
</a>
<nav class="md-nav" aria-label="ImplAmbiguityPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmbiguityPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmbiguityPort.resolve_ambiguity" class="md-nav__link">
<span class="md-ellipsis">
resolve_ambiguity
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmountBalancePort" class="md-nav__link">
<span class="md-ellipsis">
ImplAmountBalancePort
</span>
</a>
<nav class="md-nav" aria-label="ImplAmountBalancePort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmountBalancePort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmountBalancePort.adjust_balance" class="md-nav__link">
<span class="md-ellipsis">
adjust_balance
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmountBalancePort.missing_number_candidates" class="md-nav__link">
<span class="md-ellipsis">
missing_number_candidates
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplAmountBalancePort.resolve" class="md-nav__link">
<span class="md-ellipsis">
resolve
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplBucketFinderPort" class="md-nav__link">
<span class="md-ellipsis">
ImplBucketFinderPort
</span>
</a>
<nav class="md-nav" aria-label="ImplBucketFinderPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplBucketFinderPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplBucketFinderPort.get_opening_balance_buckets" class="md-nav__link">
<span class="md-ellipsis">
get_opening_balance_buckets
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort" class="md-nav__link">
<span class="md-ellipsis">
ImplDatePort
</span>
</a>
<nav class="md-nav" aria-label="ImplDatePort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.get_dates" class="md-nav__link">
<span class="md-ellipsis">
get_dates
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.parse_date" class="md-nav__link">
<span class="md-ellipsis">
parse_date
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.reconcile_date" class="md-nav__link">
<span class="md-ellipsis">
reconcile_date
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.reconcile_date_full" class="md-nav__link">
<span class="md-ellipsis">
reconcile_date_full
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.reconcile_date_partial" class="md-nav__link">
<span class="md-ellipsis">
reconcile_date_partial
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.reorder_lines_by_date" class="md-nav__link">
<span class="md-ellipsis">
reorder_lines_by_date
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDatePort.split_line_by_date" class="md-nav__link">
<span class="md-ellipsis">
split_line_by_date
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDescPort" class="md-nav__link">
<span class="md-ellipsis">
ImplDescPort
</span>
</a>
<nav class="md-nav" aria-label="ImplDescPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDescPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDescPort.extract_description" class="md-nav__link">
<span class="md-ellipsis">
extract_description
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplDescPort.fix_ocr" class="md-nav__link">
<span class="md-ellipsis">
fix_ocr
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplNumberPort" class="md-nav__link">
<span class="md-ellipsis">
ImplNumberPort
</span>
</a>
<nav class="md-nav" aria-label="ImplNumberPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplNumberPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplNumberPort.get_numbers" class="md-nav__link">
<span class="md-ellipsis">
get_numbers
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplNumberPort.get_opening_balance" class="md-nav__link">
<span class="md-ellipsis">
get_opening_balance
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline" class="md-nav__link">
<span class="md-ellipsis">
ImplPDFExtractionPipeline
</span>
</a>
<nav class="md-nav" aria-label="ImplPDFExtractionPipeline">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.run" class="md-nav__link">
<span class="md-ellipsis">
run
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplRawLinesPort" class="md-nav__link">
<span class="md-ellipsis">
ImplRawLinesPort
</span>
</a>
<nav class="md-nav" aria-label="ImplRawLinesPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplRawLinesPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplRawLinesPort.extract" class="md-nav__link">
<span class="md-ellipsis">
extract
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplSplitterPort" class="md-nav__link">
<span class="md-ellipsis">
ImplSplitterPort
</span>
</a>
<nav class="md-nav" aria-label="ImplSplitterPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplSplitterPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplSplitterPort.split_blocks" class="md-nav__link">
<span class="md-ellipsis">
split_blocks
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTransactionParserPort" class="md-nav__link">
<span class="md-ellipsis">
ImplTransactionParserPort
</span>
</a>
<nav class="md-nav" aria-label="ImplTransactionParserPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTransactionParserPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTransactionParserPort.parse" class="md-nav__link">
<span class="md-ellipsis">
parse
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTxnBlocksPort" class="md-nav__link">
<span class="md-ellipsis">
ImplTxnBlocksPort
</span>
</a>
<nav class="md-nav" aria-label="ImplTxnBlocksPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTxnBlocksPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTxnBlocksPort.extract" class="md-nav__link">
<span class="md-ellipsis">
extract
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTxnDictsPort" class="md-nav__link">
<span class="md-ellipsis">
ImplTxnDictsPort
</span>
</a>
<nav class="md-nav" aria-label="ImplTxnDictsPort">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTxnDictsPort-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ImplTxnDictsPort.extract" class="md-nav__link">
<span class="md-ellipsis">
extract
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl-functions" class="md-nav__link">
<span class="md-ellipsis">
Functions
</span>
</a>
<nav class="md-nav" aria-label="Functions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.clean_num" class="md-nav__link">
<span class="md-ellipsis">
clean_num
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.normalize" class="md-nav__link">
<span class="md-ellipsis">
normalize
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.ocr_all_pages" class="md-nav__link">
<span class="md-ellipsis">
ocr_all_pages
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#pipelines.extraction.pdf.impl.rasterize_pdf" class="md-nav__link">
<span class="md-ellipsis">
rasterize_pdf
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1 id="impl">Impl</h1>
<div class="doc doc-object doc-module">
<h2 id="pipelines.extraction.pdf.impl" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-module"></code> <span class="doc doc-object-name doc-module-name">pipelines.extraction.pdf.impl</span>
</h2>
<div class="doc doc-contents first">
<h3 id="pipelines.extraction.pdf.impl--summary">Summary</h3>
<p>Concrete pdf-family implementations.</p>
<hr />
<p>The pdf family is the OCR text chain; each concrete class REDECLARES its port
slots with CONCRETE types — this pinned typing is what informs the ports to be
used, exactly as in the old <code>pipelines/extraction_pipeline_impl.py</code>.</p>
<p>This models the real <code>domain/extraction</code> pdf path as a hexa composition tree:</p>
<ul>
<li>ImplDatePort : port of domain.extraction.ports.date.DatePort</li>
<li>ImplBucketFinderPort: port of BucketFinderAdaptor.get_opening_balance_buckets</li>
<li>ImplSplitterPort : port of TransactionSplitterAdaptor.split_blocks</li>
<li>ImplTransactionParserPort: port of TransactionParserAdaptor.parse</li>
<li>ImplRawLinesPort : port of PdfRawLinesAdaptor (ocr_all_pages + normalize)</li>
</ul>
<div class="doc doc-children">
<h3 id="pipelines.extraction.pdf.impl-classes">Classes</h3>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplAmbiguityPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplAmbiguityPort</span>
</h4>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span>
<span class="normal"><a href="#__codelineno-0-4">4</a></span>
<span class="normal"><a href="#__codelineno-0-5">5</a></span>
<span class="normal"><a href="#__codelineno-0-6">6</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">ImplAmbiguityPort</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">fetch_request_id</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a> <span class="n">pause_on_ambiguity</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4"></a> <span class="n">resolved_choices</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5"></a> <span class="n">resolver</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6"></a><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ports.AmbiguityPort" href="../../shared/ports/#pipelines.extraction.shared.ports.AmbiguityPort">AmbiguityPort</a></code>, <code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ambiguity.AmbiguityHandler" href="../../shared/ambiguity/#pipelines.extraction.shared.ambiguity.AmbiguityHandler">AmbiguityHandler</a></code></p>
<p>Concrete ambiguity leaf — delegates to <code>AmbiguityHandler</code>.</p>
<p>Initialize the ambiguity handler.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>fetch_request_id</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Identifier correlating this resolution to a
fetch request. Defaults to <code>""</code>.</p>
</div>
</td>
<td>
<code>&#39;&#39;</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>pause_on_ambiguity</code></td>
<td>
<code>bool</code>
</td>
<td>
<div class="doc-md-description">
<p>Whether to raise <code>PauseForResolution</code>
when unresolved. Defaults to <code>True</code>.</p>
</div>
</td>
<td>
<code>True</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>resolved_choices</code></td>
<td>
<code><span title="typing.Optional">Optional</span>[dict]</code>
</td>
<td>
<div class="doc-md-description">
<p>Prior choices keyed by candidate
key. Defaults to <code>None</code> (becomes an empty dict).</p>
</div>
</td>
<td>
<code>None</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>resolver</code></td>
<td>
<code><span title="typing.Optional">Optional</span>[<span title="typing.Callable">Callable</span>]</code>
</td>
<td>
<div class="doc-md-description">
<p>Optional resolver hook. Defaults to
<code>None</code>.</p>
</div>
</td>
<td>
<code>None</code>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplAmbiguityPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplAmbiguityPort.resolve_ambiguity" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">resolve_ambiguity</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span>
<span class="normal"><a href="#__codelineno-0-4">4</a></span>
<span class="normal"><a href="#__codelineno-0-5">5</a></span>
<span class="normal"><a href="#__codelineno-0-6">6</a></span>
<span class="normal"><a href="#__codelineno-0-7">7</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">resolve_ambiguity</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">line</span><span class="p">,</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a> <span class="n">ocr_amount</span><span class="p">,</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4"></a> <span class="n">ocr_balance</span><span class="p">,</span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5"></a> <span class="n">prev_balance</span><span class="p">,</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6"></a> <span class="n">candidates</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7"></a><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Resolve ambiguity via <code>AmbiguityHandler.resolve_ambiguity</code>.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Raw transaction line.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>ocr_amount</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>OCR amount.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>ocr_balance</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>OCR balance.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev_balance</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Previous transaction balance.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>candidates</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Candidate (amount, balance) pairs; default <code>set()</code>.</p>
</div>
</td>
<td>
<code>None</code>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>Set with the chosen pair, or <code>None</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplAmountBalancePort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplAmountBalancePort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ports.AmountBalancePort" href="../../shared/ports/#pipelines.extraction.shared.ports.AmountBalancePort">AmountBalancePort</a></code></p>
<p>Concrete amount/balance leaf — resolves via <code>ResolutionContext</code>.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplAmountBalancePort.number">number</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplNumberPort" href="#pipelines.extraction.pdf.impl.ImplNumberPort">ImplNumberPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Number extraction leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplAmountBalancePort.ambiguity">ambiguity</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplAmbiguityPort" href="#pipelines.extraction.pdf.impl.ImplAmbiguityPort">ImplAmbiguityPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Ambiguity resolution leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplAmountBalancePort.handler">handler</span></code></td>
<td>
<code><span title="typing.Optional">Optional</span>[<a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ambiguity.AmbiguityHandler" href="../../shared/ambiguity/#pipelines.extraction.shared.ambiguity.AmbiguityHandler">AmbiguityHandler</a>]</code>
</td>
<td>
<div class="doc-md-description">
<p>Optional override handler.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplAmountBalancePort.trust_fallback">trust_fallback</span></code></td>
<td>
<code><span title="typing.Optional">Optional</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>Fallback policy.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplAmountBalancePort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplAmountBalancePort.adjust_balance" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">adjust_balance</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">adjust_balance</span><span class="p">(</span><span class="n">balance</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Adjust an OCR balance (no-op base).</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>balance</code></td>
<td>
<code>float</code>
</td>
<td>
<div class="doc-md-description">
<p>OCR balance.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Transaction line.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>float</code></td> <td>
<code>float</code>
</td>
<td>
<div class="doc-md-description">
<p>The balance, unmodified.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplAmountBalancePort.missing_number_candidates" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">missing_number_candidates</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">missing_number_candidates</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Provide candidates for one-number lines (no-op base).</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>ctx</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>The active <code>ResolutionContext</code>.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>None.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplAmountBalancePort.resolve" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">resolve</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">resolve</span><span class="p">(</span><span class="n">amount</span><span class="p">,</span> <span class="n">balance</span><span class="p">,</span> <span class="n">prev_balance</span><span class="p">,</span> <span class="n">line</span><span class="p">,</span> <span class="n">numbers</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Resolve (amount, balance) via <code>ResolutionContext</code>.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>amount</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>OCR amount.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>balance</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>OCR balance (adjusted first).</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev_balance</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Previous transaction balance.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Raw transaction line.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>numbers</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Extracted numbers; default None.</p>
</div>
</td>
<td>
<code>None</code>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>(signed amount, resolved balance) tuple.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplBucketFinderPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplBucketFinderPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.BucketFinderPort" href="../abc/#pipelines.extraction.pdf.abc.BucketFinderPort">BucketFinderPort</a></code></p>
<p>Concrete bucket finder — splits raw lines at B/F and opening markers.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplBucketFinderPort.number">number</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplNumberPort" href="#pipelines.extraction.pdf.impl.ImplNumberPort">ImplNumberPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Number extraction leaf.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplBucketFinderPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplBucketFinderPort.get_opening_balance_buckets" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">get_opening_balance_buckets</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">get_opening_balance_buckets</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">lines</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">limit_first</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_offset</span><span class="o">=</span><span class="mi">0</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Divide raw lines into opening-balance buckets.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>lines</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Raw text lines.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>limit_first</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Keep only the first bucket.</p>
</div>
</td>
<td>
<code>False</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>line_offset</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Offset added to starting indices.</p>
</div>
</td>
<td>
<code>0</code>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>List of <code>(start, end, opening_balance)</code> triples.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplDatePort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplDatePort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ports.DatePort" href="../../shared/ports/#pipelines.extraction.shared.ports.DatePort">DatePort</a></code></p>
<p>Concrete date leaf: parse, split, reconcile, and reorder dates.</p>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplDatePort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.get_dates" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">get_dates</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">get_dates</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Extract the leading date and text tail from a line.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Text line.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.Optional">Optional</span>[<span title="typing.Tuple">Tuple</span>[str, str]]</code>
</td>
<td>
<div class="doc-md-description">
<p>Optional[Tuple[str, str]]: <code>(date_str, date_tail)</code> or <code>None</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.parse_date" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">parse_date</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">parse_date</span><span class="p">(</span><span class="n">date_str</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Parse <code>DD-MM-YYYY</code> (or <code>DD/MM/YYYY</code>) into a date.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>date_str</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Date string.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="datetime.date">date</span></code>
</td>
<td>
<div class="doc-md-description">
<p>datetime.date: The parsed date.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.reconcile_date" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">reconcile_date</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">reconcile_date</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">date_str</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">prev_date_str</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Reconcile an OCR date against the previous transaction date.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>date_str</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>OCR date string.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev_date_str</code></td>
<td>
<code><span title="typing.Optional">Optional</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>Previous transaction date string.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>str</code></td> <td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Reconciliated date as <code>DD-MM-YYYY</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.reconcile_date_full" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">reconcile_date_full</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">reconcile_date_full</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">date_str</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">prev</span><span class="p">:</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Reconcile a date string against a full reference date.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>date_str</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>OCR date string.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev</code></td>
<td>
<code><span title="datetime.date">date</span></code>
</td>
<td>
<div class="doc-md-description">
<p>Previous transaction date.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.Optional">Optional</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>Optional[str]: Reconciliated <code>DD-MM-YYYY</code> string or <code>None</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.reconcile_date_partial" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">reconcile_date_partial</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">reconcile_date_partial</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">date_str</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">prev</span><span class="p">:</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Reconcile a partial <code>MM-YYYY</code> date against a reference date.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>date_str</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Partial OCR date string.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev</code></td>
<td>
<code><span title="datetime.date">date</span></code>
</td>
<td>
<div class="doc-md-description">
<p>Previous transaction date.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.Optional">Optional</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>Optional[str]: Reconciliated <code>DD-MM-YYYY</code> string or <code>None</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.reorder_lines_by_date" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">reorder_lines_by_date</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">reorder_lines_by_date</span><span class="p">(</span><span class="n">txn_lines</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Move the dated line to the front of a transaction block.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>txn_lines</code></td>
<td>
<code><span title="typing.List">List</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>Transaction block lines.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.List">List</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>List[str]: Reordered lines.</p>
</div>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Raises:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code>ValueError</code>
</td>
<td>
<div class="doc-md-description">
<p>When no dated line is present in the block.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDatePort.split_line_by_date" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">split_line_by_date</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">split_line_by_date</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Split a merged line into segments at date boundaries.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Possibly merged OCR line.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.List">List</span>[str]</code>
</td>
<td>
<div class="doc-md-description">
<p>List[str]: Line segments split at date boundaries.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplDescPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplDescPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ports.DescPort" href="../../shared/ports/#pipelines.extraction.shared.ports.DescPort">DescPort</a></code></p>
<p>Concrete description leaf — slices at the first starter marker.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplDescPort.starters">starters</span></code></td>
<td>
<code><span title="typing.Optional">Optional</span>[<span title="typing.List">List</span>[str]]</code>
</td>
<td>
<div class="doc-md-description">
<p>Description starter markers.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplDescPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDescPort.extract_description" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">extract_description</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">extract_description</span><span class="p">(</span><span class="n">description</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Extract and clean the transaction description.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>description</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Raw description text.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>str</code></td> <td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Cleaned description.</p>
</div>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Raises:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code>NotImplementedError</code>
</td>
<td>
<div class="doc-md-description">
<p>When no starters are configured.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplDescPort.fix_ocr" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">fix_ocr</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">fix_ocr</span><span class="p">(</span><span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Fix OCR artifacts in the description text (no-op base).</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>text</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Text to fix.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>str</code></td> <td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Fixed text.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplNumberPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplNumberPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.ports.NumberPort" href="../../shared/ports/#pipelines.extraction.shared.ports.NumberPort">NumberPort</a></code></p>
<p>Concrete number leaf — prefers trailing decimals, else the last numbers.</p>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplNumberPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplNumberPort.get_numbers" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">get_numbers</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">get_numbers</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Extract monetary numbers, preferring trailing decimals.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Text line to scan.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.List">List</span>[float]</code>
</td>
<td>
<div class="doc-md-description">
<p>List[float]: Cleaned monetary numbers.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplNumberPort.get_opening_balance" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">get_opening_balance</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">get_opening_balance</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">float</span><span class="p">]</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Return the last number as the opening balance.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>line</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Text line to scan.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code><span title="typing.Optional">Optional</span>[float]</code>
</td>
<td>
<div class="doc-md-description">
<p>Optional[float]: The last number, else <code>None</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplPDFExtractionPipeline</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.PDFExtractionPipeline" href="../abc/#pipelines.extraction.pdf.abc.PDFExtractionPipeline">PDFExtractionPipeline</a></code></p>
<p>Concrete pdf graph root.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.pipeline">pipeline</span></code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Pipeline tag ("heuristic").</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.trust_fallback">trust_fallback</span></code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Fallback policy for amount/balance trust.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.ingest">ingest</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.impl.ImplIngestPort" href="../../shared/impl/#pipelines.extraction.shared.impl.ImplIngestPort">ImplIngestPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Ingest stage.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.raw_lines">raw_lines</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplRawLinesPort" href="#pipelines.extraction.pdf.impl.ImplRawLinesPort">ImplRawLinesPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Raw-lines stage.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.txn_blocks">txn_blocks</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplTxnBlocksPort" href="#pipelines.extraction.pdf.impl.ImplTxnBlocksPort">ImplTxnBlocksPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Txn-blocks stage.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.txn_dicts">txn_dicts</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplTxnDictsPort" href="#pipelines.extraction.pdf.impl.ImplTxnDictsPort">ImplTxnDictsPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Txn-dicts stage.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.raw_expense">raw_expense</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.shared.impl.ImplRawExpensePort" href="../../shared/impl/#pipelines.extraction.shared.impl.ImplRawExpensePort">ImplRawExpensePort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Terminal raw-expense stage.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplPDFExtractionPipeline.run" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">run</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">run</span><span class="p">(</span><span class="n">source</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Run the pdf extraction chain end-to-end.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>source</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Raw extraction source.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>List of raw expense records.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplRawLinesPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplRawLinesPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.RawLinesPort" href="../abc/#pipelines.extraction.pdf.abc.RawLinesPort">RawLinesPort</a></code></p>
<p>Concrete raw-lines leaf — OCRs PDF bytes into text lines.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplRawLinesPort.covert_to_image">covert_to_image</span></code></td>
<td>
<code>bool</code>
</td>
<td>
<div class="doc-md-description">
<p>Binarize pages via image conversion.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplRawLinesPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplRawLinesPort.extract" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">extract</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">extract</span><span class="p">(</span><span class="n">content</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Extract raw OCR text lines from content.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>content</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>PDF bytes, Content, or dict payload.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>List of raw text lines.</p>
</div>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Raises:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code>TypeError</code>
</td>
<td>
<div class="doc-md-description">
<p>When content is not PDF bytes or Content with <code>.raw</code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplSplitterPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplSplitterPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.SplitterPort" href="../abc/#pipelines.extraction.pdf.abc.SplitterPort">SplitterPort</a></code></p>
<p>Concrete splitter — splits bucket lines into transaction blocks.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplSplitterPort.number">number</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplNumberPort" href="#pipelines.extraction.pdf.impl.ImplNumberPort">ImplNumberPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Number extraction leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplSplitterPort.date">date</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplDatePort" href="#pipelines.extraction.pdf.impl.ImplDatePort">ImplDatePort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Date parsing leaf.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplSplitterPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplSplitterPort.split_blocks" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">split_blocks</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span>
<span class="normal"><a href="#__codelineno-0-4">4</a></span>
<span class="normal"><a href="#__codelineno-0-5">5</a></span>
<span class="normal"><a href="#__codelineno-0-6">6</a></span>
<span class="normal"><a href="#__codelineno-0-7">7</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">split_blocks</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">lines</span><span class="p">,</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a> <span class="o">*</span><span class="p">,</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4"></a> <span class="n">has_header</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5"></a> <span class="n">min_numbers</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6"></a> <span class="n">detect_date_ranges</span><span class="o">=</span><span class="kc">False</span>
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7"></a><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Split bucket lines into transaction blocks.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>lines</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Bucket lines.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>has_header</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Whether a header precedes the rows.</p>
</div>
</td>
<td>
<code>False</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>min_numbers</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Minimum numbers for a split.</p>
</div>
</td>
<td>
<code>3</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>detect_date_ranges</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Detect date-range lines.</p>
</div>
</td>
<td>
<code>False</code>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>List of transaction block texts.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplTransactionParserPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplTransactionParserPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.TransactionParserPort" href="../abc/#pipelines.extraction.pdf.abc.TransactionParserPort">TransactionParserPort</a></code></p>
<p>Concrete transaction parser — one block to one txn dict.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTransactionParserPort.number">number</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplNumberPort" href="#pipelines.extraction.pdf.impl.ImplNumberPort">ImplNumberPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Number extraction leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTransactionParserPort.date">date</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplDatePort" href="#pipelines.extraction.pdf.impl.ImplDatePort">ImplDatePort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Date parsing leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTransactionParserPort.desc">desc</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplDescPort" href="#pipelines.extraction.pdf.impl.ImplDescPort">ImplDescPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Description extraction leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTransactionParserPort.amount_balance">amount_balance</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplAmountBalancePort" href="#pipelines.extraction.pdf.impl.ImplAmountBalancePort">ImplAmountBalancePort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Amount/balance resolution leaf.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplTransactionParserPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplTransactionParserPort.parse" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">parse</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">parse</span><span class="p">(</span><span class="n">txn_text</span><span class="p">,</span> <span class="n">prev_date_str</span><span class="p">,</span> <span class="n">prev_balance</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Parse a transaction block into a txn dict.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>txn_text</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Transaction block text.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev_date_str</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Previous transaction date string.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>prev_balance</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Running balance from the previous transaction.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>Txn dict, or <code>None</code> when the block has no usable date/numbers.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplTxnBlocksPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplTxnBlocksPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.TxnBlocksPort" href="../abc/#pipelines.extraction.pdf.abc.TxnBlocksPort">TxnBlocksPort</a></code></p>
<p>Concrete txn-blocks stage — buckets plus per-bucket splitting.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTxnBlocksPort.bucket_finder">bucket_finder</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplBucketFinderPort" href="#pipelines.extraction.pdf.impl.ImplBucketFinderPort">ImplBucketFinderPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Bucket-finding leaf.</p>
</div>
</td>
</tr>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTxnBlocksPort.splitter">splitter</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplSplitterPort" href="#pipelines.extraction.pdf.impl.ImplSplitterPort">ImplSplitterPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Block-splitting leaf.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplTxnBlocksPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplTxnBlocksPort.extract" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">extract</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">extract</span><span class="p">(</span><span class="n">raw_lines</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Extract txn blocks keyed by opening balance.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>raw_lines</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Raw OCR text lines.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>Dict[float, List[str]]: Opening balance → block texts.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="doc doc-object doc-class">
<h4 id="pipelines.extraction.pdf.impl.ImplTxnDictsPort" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">ImplTxnDictsPort</span>
</h4>
<div class="doc doc-contents ">
<p class="doc doc-class-bases">
Bases: <code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.abc.TxnDictsPort" href="../abc/#pipelines.extraction.pdf.abc.TxnDictsPort">TxnDictsPort</a></code></p>
<p>Concrete txn-dicts stage — parses blocks in balance-chained order.</p>
<p><span class="doc-section-title">Attributes:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code><span title="pipelines.extraction.pdf.impl.ImplTxnDictsPort.parser">parser</span></code></td>
<td>
<code><a class="autorefs autorefs-internal" title="pipelines.extraction.pdf.impl.ImplTransactionParserPort" href="#pipelines.extraction.pdf.impl.ImplTransactionParserPort">ImplTransactionParserPort</a></code>
</td>
<td>
<div class="doc-md-description">
<p>Transaction parsing leaf.</p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="doc doc-children">
<h5 id="pipelines.extraction.pdf.impl.ImplTxnDictsPort-functions">Functions</h5>
<div class="doc doc-object doc-function">
<h6 id="pipelines.extraction.pdf.impl.ImplTxnDictsPort.extract" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">extract</span>
</h6>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">extract</span><span class="p">(</span><span class="n">txn_blocks</span><span class="p">)</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Extract balance-chained txn dicts from blocks.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>txn_blocks</code></td>
<td>
</td>
<td>
<div class="doc-md-description">
<p>Opening balance → block texts.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
</td>
<td>
<div class="doc-md-description">
<p>List of txn dicts.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<h3 id="pipelines.extraction.pdf.impl-functions">Functions</h3>
<div class="doc doc-object doc-function">
<h4 id="pipelines.extraction.pdf.impl.clean_num" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-function"></code> <span class="doc doc-object-name doc-function-name">clean_num</span>
</h4>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">clean_num</span><span class="p">(</span><span class="n">s</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Port of domain.extraction.ports.pdf.clean_num.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>s</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Numeric string to clean.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>float</code></td> <td>
<code>float</code>
</td>
<td>
<div class="doc-md-description">
<p>Parsed numeric value; <code>0.0</code> when the string has no digits.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h4 id="pipelines.extraction.pdf.impl.normalize" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-function"></code> <span class="doc doc-object-name doc-function-name">normalize</span>
</h4>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">normalize</span><span class="p">(</span><span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Normalize OCR text: fix artifacts, strip separators, drop commas.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>text</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Raw OCR text.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>str</code></td> <td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Normalized text.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h4 id="pipelines.extraction.pdf.impl.ocr_all_pages" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-function"></code> <span class="doc doc-object-name doc-function-name">ocr_all_pages</span>
</h4>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">ocr_all_pages</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">pdf_bytes</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">covert_to_image</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">None</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Run OCR over every PDF page, returning per-page text.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>pdf_bytes</code></td>
<td>
<code>bytes</code>
</td>
<td>
<div class="doc-md-description">
<p>PDF file bytes.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>covert_to_image</code></td>
<td>
<code>bool</code>
</td>
<td>
<div class="doc-md-description">
<p>Binarize pages through image conversion.</p>
</div>
</td>
<td>
<code>None</code>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>list</code></td> <td>
<code>list</code>
</td>
<td>
<div class="doc-md-description">
<p>One OCR text string per page.</p>
</div>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Raises:</span></p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td>
<code>ImportError</code>
</td>
<td>
<div class="doc-md-description">
<p>When pytesseract/Pillow are unavailable.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="doc doc-object doc-function">
<h4 id="pipelines.extraction.pdf.impl.rasterize_pdf" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-function"></code> <span class="doc doc-object-name doc-function-name">rasterize_pdf</span>
</h4>
<div class="language-python doc-signature highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-1">1</a></span>
<span class="normal"><a href="#__codelineno-0-2">2</a></span>
<span class="normal"><a href="#__codelineno-0-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1"></a><span class="nf">rasterize_pdf</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2"></a> <span class="n">pdf_bytes</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">out_dir</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dpi</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">300</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3"></a><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span>
</span></code></pre></div></td></tr></table></div>
<div class="doc doc-contents ">
<p>Rasterize PDF bytes into JPEG page images via pdftoppm.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>pdf_bytes</code></td>
<td>
<code>bytes</code>
</td>
<td>
<div class="doc-md-description">
<p>PDF file bytes.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>out_dir</code></td>
<td>
<code>str</code>
</td>
<td>
<div class="doc-md-description">
<p>Directory to write the PDF and page images.</p>
</div>
</td>
<td>
<em>required</em>
</td>
</tr>
<tr class="doc-section-item">
<td><code>dpi</code></td>
<td>
<code>int</code>
</td>
<td>
<div class="doc-md-description">
<p>Render resolution. Defaults to 300.</p>
</div>
</td>
<td>
<code>300</code>
</td>
</tr>
</tbody>
</table>
<p><span class="doc-section-title">Returns:</span></p>
<table>
<thead>
<tr>
<th>Name</th> <th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="doc-section-item">
<td><code>list</code></td> <td>
<code>list</code>
</td>
<td>
<div class="doc-md-description">
<p>Sorted list of generated JPEG page paths.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</article>
</div>
<script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
<button type="button" class="md-top md-icon" data-md-component="top" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
Back to top
</button>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../../../..", "features": ["navigation.sections", "navigation.expand", "navigation.top", "navigation.instant", "navigation.tracking", "navigation.indexes", "content.code.copy", "content.code.annotate", "content.tabs.link", "content.action.edit", "search.highlight", "search.share", "search.suggest"], "search": "../../../../assets/javascripts/workers/search.973d3a69.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
<script src="../../../../assets/javascripts/bundle.f55a23d4.min.js"></script>
</body>
</html>