Skip to content

ReByteAI/super-extract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Super Extract

Structured information extraction with character-level source grounding. Extract entities from PDFs, DOCX, and text with exact position mapping and interactive visualization.

Super Extract Demo

Inspired by google/langextract.

What It Does

Super Extract is an AI coding agent skill that:

  1. Reads documents (PDF, DOCX, plain text) via companion pdf/docx skills
  2. Extracts structured entities using LLM few-shot prompting
  3. Aligns extractions to exact character positions in the source text using token-based alignment (difflib)
  4. Visualizes results as highlighted interactive HTML

Skill Structure

skill/
  SKILL.md        — Agent instructions (extraction pipeline, visualization template)
  bin/
    align.py      — Tokenizer + WordAligner (ported from google/langextract)

align.py

The alignment engine is a standalone Python script (~380 lines, zero dependencies beyond stdlib) that:

  • Tokenizes text via RegexTokenizer (spaced languages) or UnicodeTokenizer (CJK, Thai, etc.)
  • Aligns extraction strings to source text using WordAligner (difflib SequenceMatcher)
  • Supports exact and fuzzy matching with configurable threshold
  • Outputs character intervals (start_pos, end_pos) for each extraction

Usage

# Pipe JSON
echo '{"source":"Patient takes Aspirin 100mg daily.","extractions":[{"extraction_class":"medication","extraction_text":"Aspirin"}]}' \
  | python3 skill/bin/align.py --stdin

# From files
python3 skill/bin/align.py --source doc.txt --extractions entities.json

# CJK text
python3 skill/bin/align.py --stdin --unicode < input.json

Output

{
  "source": "Patient takes Aspirin 100mg daily.",
  "extractions": [
    {
      "extraction_class": "medication",
      "extraction_text": "Aspirin",
      "char_interval": {"start_pos": 14, "end_pos": 21},
      "alignment_status": "match_exact",
      "token_interval": {"start_index": 2, "end_index": 3}
    }
  ]
}

How It Differs from google/langextract

google/langextract is a full Python library that bundles its own LLM inference, provider system, and batch processing. Super Extract strips that down to just the alignment engine — because the AI agent is the LLM. The agent handles prompting, chunking, and visualization natively.

Component google/langextract super-extract
LLM inference Built-in (Gemini, OpenAI, Ollama) Agent is the LLM
Prompt template Q&A format in code SKILL.md instructions
Tokenizer RegexTokenizer + UnicodeTokenizer Same (ported)
Alignment WordAligner (difflib) Same (ported)
Visualization Jupyter HTML widget Agent-generated HTML
Batch processing ThreadPoolExecutor Agent parallelism

License

Apache 2.0 — alignment code ported from google/langextract (Apache 2.0).

About

Structured information extraction with character-level source grounding. Extract entities from PDFs, DOCX, and text with exact position mapping and interactive visualization.

Resources

License

Stars

9 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages