doc-intelligence-promotion
Post-processing pipeline for document extraction — tables to CSV, calc reports from extracted data, charts to calibration metadata. Includes table→YAML→code→calc-report workflow.
Best use case
doc-intelligence-promotion is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Post-processing pipeline for document extraction — tables to CSV, calc reports from extracted data, charts to calibration metadata. Includes table→YAML→code→calc-report workflow.
Teams using doc-intelligence-promotion should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/doc-intelligence-promotion/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How doc-intelligence-promotion Compares
| Feature / Agent | doc-intelligence-promotion | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Post-processing pipeline for document extraction — tables to CSV, calc reports from extracted data, charts to calibration metadata. Includes table→YAML→code→calc-report workflow.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Document Intelligence Promotion
> Single-pass extraction + multi-stage post-processing pipeline.
>
> **Note**: This pipeline uses pdfplumber for single-document extraction (not batch).
> For batch text extraction across the corpus, use pdftotext via subprocess — see
> `pdf/pdftotext-poppler` sub-skill.
## Architecture
```
PDF/DOCX → parser (single read) → manifest.yaml
↓
deep_extract.py (post-processors):
├── table_exporter.py → CSV files
├── worked_example_parser.py → pytest files
└── chart_extractor.py → images + metadata YAML
```
## CLI Commands
```bash
# Single document — deep extraction with report
uv run --no-project python scripts/data/doc-intelligence/deep-extract.py \
--input <file.pdf> --domain naval-architecture --report --verbose
# From existing manifest
uv run --no-project python scripts/data/doc-intelligence/deep-extract.py \
--manifest <manifest.yaml> --report
# Batch extraction with deep post-processing
uv run --no-project python scripts/data/doc-intelligence/batch-extract.py \
--queue <queue.yaml> --deep --verbose
# Promote extracted artifacts to code
uv run --no-project python scripts/data/doc-intelligence/promote-to-code.py \
--types tables worked_examples curves
```
## Post-Processor Details
### Tables (`table_exporter.py`)
- Reads `ExtractedTable` from manifest → writes CSV with header + rows
- Idempotent (content-hash check)
- Generates JSONL records for promoter integration
### Worked Examples (`worked_example_parser.py`)
- Parses "Example N.N:" title + "Given:" inputs + "Solution:" output
- Extracts: symbol, value, unit for each input parameter
- Generates real pytest files with `pytest.approx(expected, rel=1e-3)`
### Charts (`chart_extractor.py`)
- Extracts embedded images from PDFs via PyMuPDF
- Filters icons/logos (min 100x80px)
- Links images to figure references by page number
- Generates calibration metadata YAML for manual digitization
## Extraction Yield Reality (WRK-1246 Assessment)
Proven yield across 420K+ corpus:
| Content type | Yield | Notes |
|-------------|-------|-------|
| tables | 69-93% | Primary extraction target |
| figure_refs | 1-52% | Metadata only; varies by stratum |
| equations | 0% | Not reliably detectable by current parsers |
| constants | 0% | Not reliably detectable by current parsers |
| procedures | 0% | Not reliably detectable by current parsers |
| worked_examples | 0% | Not reliably detectable by current parsers |
Focus extraction effort on tables. Other content types exist in the manifest schema but
produce no usable output from the current pipeline.
## Table Quality Gate
Before promoting extracted tables, apply three quality filters:
1. **Content-hash dedup**: Remove identical repeated tables. IHS watermark tables and
repeated header/footer tables appear across many pages — hash each table's content
(header + rows) and deduplicate.
2. **Min-content threshold**: Skip tables with fewer than 3 data rows or fewer than 2
numeric columns. These are typically formatting artifacts, not engineering data.
3. **LLM quality rating**: Rate each surviving table as `usable` / `partial` / `junk`
via Haiku. Usable tables have clear headers, consistent units, and meaningful data.
Partial tables may need manual cleanup. Junk tables are formatting noise.
## Chart Extraction Note
Chart extraction is metadata-only — the pipeline captures figure references, captions,
and page locations but does not extract the image content itself. Image extraction
requires PyMuPDF (fitz) and is tracked under WRK-1257.
## Table → YAML → Code → Calc Report (WRK-1188 Learning)
**Primary workflow for engineering standards** (not textbook example parsing):
```
Extracted tables (CSV)
↓ promote to data/standards/promoted/<standard>/
YAML calc report inputs (from table data)
↓ validate against existing Python code
Code-validated outputs
↓ generate-calc-report.py
HTML calculation report
```
### Steps
1. **Deep-extract** the PDF: `deep-extract.py --input <pdf> --domain <domain> --report`
2. **Review tables**: identify high-value reference data (constants, coefficients, safety factors)
3. **Promote tables**: copy to `data/standards/promoted/<standard>/` with clean names
4. **Check existing code**: does `digitalmodel/` or `assetutilities/` already implement this?
5. **Create calc report YAML**: map extracted table values to inputs, compute outputs
6. **Validate**: run Python code with same inputs, compare outputs
7. **Generate HTML**: `generate-calc-report.py <calc-report>.yaml`
### Proven Examples
| Calc Report | Standard | Tables Used |
|-------------|----------|-------------|
| `cp-anode-design-dnv-rp-b401.yaml` | DNV-RP-B401 | Tables 10-1 to 10-8 |
| `pipeline-stability-dnv-rp-f109.yaml` | DNV-RP-F109 | Table 3-5 |
| `fatigue-sn-curve-dnv-rp-c203.yaml` | DNV-RP-C203 | Table 2-1 (14 S-N curves) |
### Why Not Worked Examples?
Engineering standards don't use textbook "Example N.N: Given: Solution:" format.
Calculation procedures are inline in numbered sections. The table→YAML→code pipeline
extracts the reference data and validates against implemented code — more reliable
than text parsing.
**WRK-1188 finding**: 0 worked examples found across 9 major engineering standards
(DNV-RP-B401, C203, F109, API RP 2A, 579-1, etc.). Deprioritize worked_example
extraction for standards; focus extraction effort on tables.
## Key Scripts
| Script | Purpose |
|--------|---------|
| `scripts/data/doc_intelligence/deep_extract.py` | Post-processing orchestrator |
| `scripts/data/doc_intelligence/table_exporter.py` | Manifest tables → CSV |
| `scripts/data/doc_intelligence/worked_example_parser.py` | Enhanced example parsing (textbooks) |
| `scripts/data/doc_intelligence/chart_extractor.py` | PDF image extraction + metadata |
| `scripts/data/doc-intelligence/deep-extract.py` | CLI entry point |
| `scripts/reporting/generate-calc-report.py` | YAML → HTML calc report |
## Promoted Table Locations
```
data/standards/promoted/
├── dnv-rp-b401/ # 8 CP design tables
├── dnv-rp-c203/ # 2 S-N curve tables (air + seawater)
└── dnv-rp-f109/ # 3 stability tables
```Related Skills
dirty-main-narrow-fix-promotion-with-stash-recovery
Promote a narrow fix from a feature/worktree into workspace-hub main when main is dirty; verify label taxonomy before issue creation and recover safely when stash reapply conflicts.
dark-intelligence-workflow
Extract calculation methodology from legacy Excel/files into clean, client-free dark intelligence archive — the canonical path for porting legacy calculations to public repos while avoiding legal/IP issues.
competitive-intelligence
Generate interactive HTML battlecards for competitive sales enablement and market positioning
xlsx-to-python-dark-intelligence-archive-generation
Sub-skill of xlsx-to-python: Dark Intelligence Archive Generation.
dark-intelligence-workflow-step-6-implement
Sub-skill of dark-intelligence-workflow: Step 6 — Implement (+1).
dark-intelligence-workflow-step-1-identify
Sub-skill of dark-intelligence-workflow: Step 1 — Identify (+4).
dark-intelligence-workflow-integration-points
Sub-skill of dark-intelligence-workflow: Integration Points.
dark-intelligence-workflow-inputs
Sub-skill of dark-intelligence-workflow: Inputs.
dark-intelligence-workflow-ac-checklist
Sub-skill of dark-intelligence-workflow: AC Checklist.
memory-management-promotion-demotion
Sub-skill of memory-management: Promotion / Demotion.
test-oversized-skill
A test fixture skill that exceeds 200 lines with multiple H2/H3 sections for split testing.
interactive-report-generator
Generate interactive HTML reports with Plotly visualizations from data analysis results. Supports dashboards, charts, and professional styling.