npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

smart-docs-parser

v1.1.2

Published

Document Details Parsing using OCR

Downloads

84

Readme

smart-docs-parser

smart-docs-parser is a NodeJs library to parse details from ID images.

https://medium.com/urbanclap-engineering/document-details-parsing-using-ocr-170bf6ad8a97

How does it work?

smart-docs-parser works in three steps:

  • Extraction of raw text from document image using OCR
  • Validation of document image based on passed document type and extracted raw text
  • Parsing relevant information from raw text using document parser

Installation

$ npm install smart-docs-parser

Usage

Configuration

Create a config folder at the root of your project. Add default.json file to the config folder.

config/default.json

{
  "smart-docs-parser": {
    "api_keys": {
      "google-vision": "YOUR_API_KEY"
    }
  }
}

Code

// ES6 import statement
import SmartDocuments from 'smart-docs-parser';

// Sample Request
const extractedDocumentDetails = await SmartDocuments.extractDocumentDetailsFromImage({
    document_url: 'https://avatars2.githubusercontent.com/u/20634933?s=40&v=4',
    document_type: 'PAN_CARD',
    ocr_library: 'google-vision'
});

// Sample Response
{ raw_text: 
   [ 'INCOME TAX DEPARTMENT',
     'GOVT. OF INDIA',
     'Permanent Account Number Card',
     'PANAM8144G',
     '/Name',
     'ID NAME',
     'frar TT /Father\'s Name',
     'FATHER NAME',
     'ae of Birth',
     '13/02/1994',
     'SIGN',
     'at / Signature',
     '' ],
  is_document_valid: true,
  document_details: 
   { document_type: 'PAN_CARD',
     identification_number: 'PANAM8144G',
     name: 'ID NAME',
     date_of_birth: '1994-02-13T00:00:00.000Z',
     fathers_name: 'FATHER NAME' 
   } 
}

Interfaces

Request

export interface ExtractDocumentDetailsFromImageRequest {
  document_url: string;
  document_type: string;
  ocr_library: string;
  custom_parser?: object; // Only for custom parsers
  custom_ocr?: object; // Only for custom OCRs
  timeout?: number; //Optional request timeout parameter, defaults to 30 secs
}

Response

export interface ExtractDocumentDetailsFromImageResponse {
  raw_text: Array<string>;
  is_document_valid: boolean;
  document_details: DocumentDetails | object;
}
interface DocumentDetails {
  document_type?: string;
  identification_number?: string;
  name?: string;
  fathers_name?: string;
  date_of_birth?: string;
  gender?: 'M'|'F';
  address?: string;
}

raw_text is the text extracted by the OCR

is_document_valid denotes whether the document is valid based on input document_type and extracted raw_text

document_details is the document information parsed using the specific document parser

Supported Request Parameters

Document Type

  • PAN CARD
    document_type: 'PAN_CARD'
  • AADHAAR CARD
    document_type: 'AADHAAR_CARD'

OCR Library

  • Google Vision
    ocr_library: 'google-vision'

Current limitations

Address parsing

Library can parse state name and pin-code but the accuracy of the system for complete address text parsing is not upto the mark due to the noise introduced by multilingual text.

Contributions

Contributions are welcome. Please create a pull-request if you want to add more document parsers, OCR libraries, test-support or enhance the existing code.

Extending smart-docs-parser

For specific use-cases

Contributing to the library

License

MIT