Structured information extraction with character-level source grounding. Extract entities from PDFs, DOCX, and text with exact position mapping and interactive visualization.
Inspired by google/langextract.
Super Extract is an AI coding agent skill that:
- Reads documents (PDF, DOCX, plain text) via companion pdf/docx skills
- Extracts structured entities using LLM few-shot prompting
- Aligns extractions to exact character positions in the source text using token-based alignment (difflib)
- Visualizes results as highlighted interactive HTML
skill/
SKILL.md — Agent instructions (extraction pipeline, visualization template)
bin/
align.py — Tokenizer + WordAligner (ported from google/langextract)
The alignment engine is a standalone Python script (~380 lines, zero dependencies beyond stdlib) that:
- Tokenizes text via
RegexTokenizer(spaced languages) orUnicodeTokenizer(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
# 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{
"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}
}
]
}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 |
Apache 2.0 — alignment code ported from google/langextract (Apache 2.0).