Add bank statement analyzer with automatic work storage

This commit is contained in:
A R R R Associates
2026-07-13 10:12:19 +05:30
parent d391e9b443
commit bbc5afe1c0
23 changed files with 1047 additions and 0 deletions
@@ -0,0 +1,25 @@
from .idfc import IDFCFirstParser
from .axis import AxisParser
from .hdfc import HDFCParser
from .indian_bank import IndianBankModernParser, IndianBankLegacyParser
from .indusind import IndusIndParser
from .kotak import KotakParser
from .sbi import SBIModernParser, SBIOtherParser
from .base import extract_text
PARSERS=[IDFCFirstParser,AxisParser,HDFCParser,IndianBankModernParser,IndianBankLegacyParser,IndusIndParser,KotakParser,SBIOtherParser,SBIModernParser]
def detect_parser(text):
scored=sorted(((p.detect(text),p) for p in PARSERS),key=lambda x:x[0],reverse=True)
if not scored or scored[0][0] <= 0: return None,0
return scored[0][1](),scored[0][0]
def parse_pdf(path, bank_hint=None):
text=extract_text(path)
if bank_hint:
for p in PARSERS:
if bank_hint.lower() in p.bank_name.lower() or bank_hint.lower() in p.__name__.lower():
return p().parse(path,text)
parser,score=detect_parser(text)
if parser is None: raise ValueError('Unsupported statement format. Add a bank-specific parser or use a supported sample format.')
return parser.parse(path,text)