Skip to main content

Efficient PDF analysis, text extraction, preprocessing, and pattern recognition with customizable configurations and utilities.

Project description

Extractlib

This is a Python package that provides a set of tools and utilities for processing and analyzing PDF documents. It includes functionality for extracting text and tables from PDFs, cleaning and preprocessing text data, and analyzing content for keywords and patterns. The package also provides a number of configuration options for customizing the behavior of the tools and utilities, making it flexible and easy to use in a variety of different contexts. Whether you need to extract data from PDF documents for data analysis, or analyze PDF content for specific keywords or patterns, this package provides the tools you need to get the job done quickly and efficiently.

Dependency Overview

Python Dependency Install

This project leverages packages

nltk == 3.8.1 
spacy == 3.5.2
PyMuPDF == 1.21.1 
camelot-py == 0.11.0 
opencv-python == 4.7.0.72 
ghostscript == 0.7

manually install supporting binaries

spacy dependencies

python -m spacy download en_core_web_sm

camelot dependencies

Ubuntu

$ apt install ghostscript python3-tk

MacOS

$ brew install ghostscript tcl-tk

windows dependency installations

Configuration

  • configuration file should be placed in the root of the project and named 'extractlib.config.json'

Example 'extractlib.config.json' File

this file should be located in the root of your project

{
  "std_out_logging": true,
  "supported_file_types": [".pdf"],
  "invalid_content_regexs": ["X{2,}"],
  "stop_words": [
    "na",
    "dependent",
    "address",
    "plans",
    "network",
    "nonnetwork",
    "additional",
    "covered"
  ],
  "keywords": {
    "dental": 5,
    "vision": 5,    
    "life": 5,
    "disability": 5
  },
  "keyword_synonyms": {
    "dental": ["orthodontic", "Endo", "Perio", "Oral"],
    "vision": ["eye", "vision", "lens", "lenses", "contact", "contacts"],
    "life": [
      "accident",
      "critical",
      "illness",
      "accidental",
      "dismember",
      "AD&D"
    ],
    "disability": []
  },
  "word_min_length": 3
}

access config variables

from extractlib.settings import config

print(json.dump(config.config_raw, indent=4))

Example implementation

from extractlib.document.process import process_document
import json

def main(file: str):
    result = process_document(file,  exclude_pages=[2,3], use_multithreading=False, split_pages_output_dir='./output', delete_split_pages=False)
    # Save the HTML content to a temporary file
    with open('temp.json', 'w') as f:
        json.dump(result, f, indent=4)


if __name__ == '__main__':

    # get working directory
    import os
    target_dir = os.path.dirname(os.path.abspath(__file__))
    main(f'{target_dir}/_testdata/PDF.pdf')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

insights-extractor-0.1.6.tar.gz (49.7 kB view details)

Uploaded Source

Built Distribution

insights_extractor-0.1.6-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file insights-extractor-0.1.6.tar.gz.

File metadata

  • Download URL: insights-extractor-0.1.6.tar.gz
  • Upload date:
  • Size: 49.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for insights-extractor-0.1.6.tar.gz
Algorithm Hash digest
SHA256 72939ca78c11cc221bb0f3d1924f76cd822b1df9a2dc2a0d231a18ed6474305c
MD5 25fd58bcca80e51552cb353d125ac327
BLAKE2b-256 03d7aa6aac4e7ef622ebb43246c75ff09c849d0ef64160ed85f9f7cc753eb74f

See more details on using hashes here.

File details

Details for the file insights_extractor-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for insights_extractor-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1a2adb36ab2ca98a335d76d6bcf4cf007a73e7763e7a4bad4d408dfa08dff4ed
MD5 22e6076c001df2977a12dad7ad21a1fa
BLAKE2b-256 d0155fb94ac25fdef759eb33f50f5c5144f1c52624c2dc17ae95ff346e71ea84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page