>_ DevTrendsen

Language

Home

Languages

Sections

Frontend Backend Mobile DevOps AI / ML GameDev Blockchain Embedded Security
Python

Text-Extract-API: Turning Documents into Structured Data Without the Headache

Ever needed to extract data from a PDF report or scanned document? The familiar nightmare of manually copying text, wrestling with crooked tables, and losing formulas? Text-extract-api offers an elegant solution to this problem, combining modern OCR technologies and language models.

What is this tool?

Text-extract-api is a Python API that allows you to:

  • Convert PDF, Word, PowerPoint, and images to Markdown or JSON
  • Extract tables, numbers, and mathematical formulas
  • Clean documents of personal data (PII)
  • Improve recognition quality using LLM models (Llama 3, MiniCPM, and others)

The main advantage is that everything works locally without sending data to cloud services.

Key features

1. Support for various formats and recognition strategies

The project supports several OCR engines:

  • EasyOCR — for fast text recognition in 30+ languages
  • MiniCPM-V — open model for commercial use
  • Llama 3.2 Vision — most accurate, but resource-intensive option
  • Remote API — for integration with external services like Marker PDF

Example command for conversion:

python client/cli.py ocr_upload --file example.pdf --strategy easyocr

2. Text improvement using LLM

After recognition, text can be further processed by a language model:

  • OCR error correction
  • Structured data extraction (e.g., converting a medical report to JSON)
  • Personal data removal
python client/cli.py ocr_upload --file medical_report.pdf --prompt_file extract_to_json.txt --model llama3.1

3. Flexible result storage

Various strategies for storing processed documents are supported:

  • Local file system
  • Google Drive
  • Amazon S3

Configuration via YAML files makes it easy to adapt the system to your needs.

Technical details

The project architecture is built on:

  • FastAPI for REST API
  • Celery for asynchronous task processing
  • Redis for result caching
  • Ollama for working with local LLM models

Two deployment options are offered:

  1. Native run (useful for Mac with Apple Silicon)
  2. Docker containers (including GPU-accelerated version)

Practical applications

Where can text-extract-api come in handy?

Law firms can automate processing of contract scans, extracting key terms into a structured format.

Medical facilities will get a tool for converting paper reports to electronic records without manual data entry.

Fintech startups will be able to parse bank statements and invoices, extracting data for accounting systems.

Researchers will appreciate the ability to digitize old books and scientific papers while preserving formulas and tables.

Get started in 5 minutes

  1. Install Docker and Ollama
  2. Clone the repository:
git clone https://github.com/CatchTheTornado/text-extract-api.git
cd text-extract-api
  1. Start the services:
docker-compose up --build
  1. Try converting your first document!

Text-extract-api is: ✅ Local solution without sending data to the cloud ✅ Support for many formats and languages ✅ Flexible integration with various storage options ✅ Quality improvement through LLM

The project will be especially appreciated by developers who need to work with documents in their applications but don't want to depend on commercial APIs or spend time implementing their own OCR.

A demo version is available for testing, and all questions can be discussed in the project's Discord community.

Related projects