rehan953 commited on
Commit
9c2be93
·
verified ·
1 Parent(s): 4dcc6ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -39,6 +39,8 @@ Primary goals for reconcile rate:
39
  - Fix 17c-html: Same as 17c using raw HTML cues when TableGridParser/header normalization would skip the table.
40
  - Fix 17d: Drop a second Electronic Debits block + DA3 table when its rows are a loose (date+amount)
41
  multiset subset of the immediately preceding DA3 table (OCR duplicate tail / wrong split).
 
 
42
  - Post-pass: dedupe 3-col Date|Description|Amount tables when one is a duplicate fragment
43
  (later subset of earlier, earlier subset of later, or identical row sets)
44
  - Fix 18: adjacent DA3 tables — if the last K data rows of table N match the first K rows of table N+1
@@ -3058,7 +3060,14 @@ def _try_split_ucb_ec_ed_from_fused_table_html(
3058
  return None
3059
 
3060
 
3061
- _UCB_CENTER_DIV = r'<div[^>]*\balign\s*=\s*["\']center["\'][^>]*>'
 
 
 
 
 
 
 
3062
 
3063
  # Optional empty centered banner only; EC/ED title divs are re-emitted after a successful split
3064
  # so we do not duplicate headings.
@@ -3182,10 +3191,10 @@ def _try_split_ucb_deposits_table_to_three(prefix: str, table_html: str):
3182
 
3183
 
3184
  _UCB_DEP_CONT_BLOCK = re.compile(
3185
- r'(<div\s+align=["\']center["\']\s*>\s*Deposits\s*\(continued\)\s*</div>\s*)'
3186
  r'(<table[^>]*>.*?</table>)'
3187
- r'(?:\s*<div\s+align=["\']center["\']\s*>\s*Electronic\s+Credits\s*</div>\s*'
3188
- r'<div\s+align=["\']center["\']\s*>\s*Electronic\s+Debits\s*</div>)?',
3189
  re.DOTALL | re.IGNORECASE,
3190
  )
3191
 
@@ -3204,8 +3213,14 @@ def _split_ucb_deposits_electronic_sections_html(text: str) -> str:
3204
  return new
3205
 
3206
  text = _UCB_DEP_CONT_BLOCK.sub(_repl, text)
3207
- text = _split_ucb_fused_ec_ed_headings_single_table_html(text)
3208
- return _ucb_strip_redundant_ed_subset_fragment(text)
 
 
 
 
 
 
3209
 
3210
 
3211
  def _parse_da3_grid_from_table_html(table_html: str):
 
39
  - Fix 17c-html: Same as 17c using raw HTML cues when TableGridParser/header normalization would skip the table.
40
  - Fix 17d: Drop a second Electronic Debits block + DA3 table when its rows are a loose (date+amount)
41
  multiset subset of the immediately preceding DA3 table (OCR duplicate tail / wrong split).
42
+ - Fix 17e: Repeat EC/ED fused + 17d passes until stable (handles chained replacements). Centered section titles
43
+ match both align=\"center\" and style=\"text-align:center\" on divs.
44
  - Post-pass: dedupe 3-col Date|Description|Amount tables when one is a duplicate fragment
45
  (later subset of earlier, earlier subset of later, or identical row sets)
46
  - Fix 18: adjacent DA3 tables — if the last K data rows of table N match the first K rows of table N+1
 
3060
  return None
3061
 
3062
 
3063
+ # Centered block titles: align= center OR inline style (Gradio / browsers vary).
3064
+ _UCB_CENTER_DIV = (
3065
+ r'(?:'
3066
+ r'<div[^>]*align\s*=\s*["\']center["\'][^>]*>'
3067
+ r'|'
3068
+ r'<div[^>]*style\s*=\s*["\'][^"\']*text-align\s*:\s*center[^"\']*["\'][^>]*>'
3069
+ r')'
3070
+ )
3071
 
3072
  # Optional empty centered banner only; EC/ED title divs are re-emitted after a successful split
3073
  # so we do not duplicate headings.
 
3191
 
3192
 
3193
  _UCB_DEP_CONT_BLOCK = re.compile(
3194
+ r'(' + _UCB_CENTER_DIV + r'\s*Deposits\s*\(continued\)\s*</div>\s*)'
3195
  r'(<table[^>]*>.*?</table>)'
3196
+ r'(?:\s*' + _UCB_CENTER_DIV + r'\s*Electronic\s+Credits\s*</div>\s*'
3197
+ + _UCB_CENTER_DIV + r'\s*Electronic\s+Debits\s*</div>)?',
3198
  re.DOTALL | re.IGNORECASE,
3199
  )
3200
 
 
3213
  return new
3214
 
3215
  text = _UCB_DEP_CONT_BLOCK.sub(_repl, text)
3216
+ # Fix 17e: repeat fused EC/ED fix + duplicate ED strip until stable (one pass can enable the next).
3217
+ for _ in range(16):
3218
+ nxt = _split_ucb_fused_ec_ed_headings_single_table_html(text)
3219
+ nxt = _ucb_strip_redundant_ed_subset_fragment(nxt)
3220
+ if nxt == text:
3221
+ break
3222
+ text = nxt
3223
+ return text
3224
 
3225
 
3226
  def _parse_da3_grid_from_table_html(table_html: str):