Giter Site home page Giter Site logo

pdfreceiptextract's Introduction

银行回单PDF解析

请求接口

PDF解析服务接口支持批量请求,所有的pdf请求需组装为一个列表(单张pdf也需要装入列表),列表每个元素的结构体需提供唯一的请求批次号RequestId、文件路径ReceiptUrl、公司编号CompanyId、银行类型BankType:

{
    Receipts :[{
        RequestId: str,
        ReceiptUrl: str,
        CompanyId: str,
        BankType: str    //一期支持"china_bank","construction_bank"
    },……
    ]
}

收到请求后立刻响应返回:

{
    Code :"succeed",
    State:"progressing"
}

回调接口

当单张pdf解析完成后(如果请求时批量请求,则每张pdf完成单独回调),将解析结果持久化至ufile,并使用回调接口通知请求方

成功:
{
    Code:"succeed",
    RequestId: str,
    ParseScoreUrl: str,
    CompanyId: str,
}

失败:
{
    Code:"failed",
    RequestId: str,
    CompanyId: str,
    Exception: str     //如没有读取到pdf、解析异常、RequestId等
}

解析数据持久化

每张回单的解析结果内涵字段提取值、所属页码

{
    'page_1':{
        'code':'succeed',
        'total':2,
        'receipt_1_1': 
            {'page':1,
              title': '国内支付业务付款回单',
              '客户号': '321799945',
              '日期': '2020年01月03日',
              '付款人账号': '474162006647',
              '收款人账号': '32250199759100000172',
              '付款人名称': '苏州宏强企业服务有限公司',
              '收款人名称': '吴中经济技术开发区兴鑫快餐配送部',
              '付款人开户行': '**银行苏州馨都广场支行',
              '收款人开户行': '**建设银行股份有限公司吴中经济开发',
              'undefined_2': '区支行',
              '金额': 'CNY55,000.00',
              'undefined_3': '人民币伍万伍仟元整'},
        'receipt_1_2': 
            {'page':1,
              'title': '国内支付业务付款回单',
              '客户号': '321799945',
              '日期': '2020年01月03日',
              '付款人账号': '474162006647',
              '收款人账号': '10552701040011061',
              '付款人名称': '苏州宏强企业服务有限公司',
              '收款人名称': '苏州欣杰通服务外包有限公司',
              '付款人开户行': '**银行苏州馨都广场支行',
              '收款人开户行': '**农业银行股份有限公司苏州长江路支',
              'undefined_2': '行',
              '金额': 'CNY6,000.00',
              'undefined_3': '人民币陆仟元整'}
    }
 }

工程部署

基于docker-compose进行fastapi工程的一键部署,通过PaaS平台的k8s实现工程的动态横向扩容

已知字段解析策略

1、对于有显式的冒号字段,直接解析key、value

2、配置已知字段表,通过正则匹配寻找字段值

未知字段解析策略

1、对于回单票面没有字段名,但容易区分的(如日期类2020年01月03日),使用正则确定类型

2、对于其他值,依次分配字段名为 undefined_n

表格类字段解析策略

暂定:配置表格类列字段名,在正则找到anchor后,使用相对位置信息找到多个值,组装列表

换行字段解析策略

暂定:配置可能换行的字段名,在正则找到anchor后,使用相对位置信息找到所有合法的文本框,进行合并

重名字段解析策略

暂定:配置可能重名的字段,使用位置信息确定

pdfreceiptextract's People

Contributors

verarong avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.