Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -207,18 +207,17 @@ def ocr_zone(image_path, y_start_frac, y_end_frac):
|
|
| 207 |
return ""
|
| 208 |
|
| 209 |
|
| 210 |
-
def fix_account_number(
|
| 211 |
-
"""If
|
| 212 |
-
find the account number from header text and inject it."""
|
| 213 |
import re
|
| 214 |
-
if not
|
| 215 |
-
return
|
| 216 |
-
if not re.search(
|
| 217 |
-
match = re.search(
|
| 218 |
if match:
|
| 219 |
-
acct = match.group(
|
| 220 |
-
|
| 221 |
-
return
|
| 222 |
|
| 223 |
|
| 224 |
def close_unclosed_html(md):
|
|
|
|
| 207 |
return ""
|
| 208 |
|
| 209 |
|
| 210 |
+
def fix_account_number(hdr):
|
| 211 |
+
"""If hdr contains Account Number: with no value, inject the number from hdr."""
|
|
|
|
| 212 |
import re
|
| 213 |
+
if not hdr:
|
| 214 |
+
return hdr
|
| 215 |
+
if "Account Number:" in hdr and not re.search("Account Number: [0-9]", hdr):
|
| 216 |
+
match = re.search("[0-9]{5,}", hdr)
|
| 217 |
if match:
|
| 218 |
+
acct = match.group(0)
|
| 219 |
+
hdr = hdr.replace("Account Number:", "Account Number: " + acct)
|
| 220 |
+
return hdr
|
| 221 |
|
| 222 |
|
| 223 |
def close_unclosed_html(md):
|