structurecc 1.0.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <h1 align="center">STRUCTURE</h1>
2
2
 
3
3
  <p align="center">
4
- <strong>Landing AI charges $500/month for agentic document structuring.<br>This is free.</strong>
4
+ <strong>Extract structured data from PDFs, Word docs, and images using Claude Code.</strong>
5
5
  </p>
6
6
 
7
7
  <p align="center">
@@ -13,76 +13,18 @@
13
13
  <img src="assets/terminal.png" alt="structurecc" width="550">
14
14
  </p>
15
15
 
16
- <p align="center">
17
- <em>Works on Mac, Windows, and Linux</em>
18
- </p>
19
-
20
- ---
21
-
22
- ## The Problem
23
-
24
- You have a 50-page PDF with figures, tables, and charts. You need that data.
25
-
26
- **Manual approach:** Screenshot each figure. Transcribe tables cell by cell. Spend hours on one document.
27
-
28
- **With structurecc:** One command. Walk away. Come back to perfectly structured markdown.
29
-
30
- ```
31
- /structure paper.pdf
32
- ```
33
-
34
- Spawns parallel AI agents. Each agent analyzes one visual element. All run simultaneously. Done in minutes, not hours.
35
-
36
- ---
37
-
38
- ## What is this?
39
-
40
- Give it a document. It extracts every image. Spawns one AI agent per image. Each agent exhaustively analyzes its element—tables become markdown tables, figures get descriptions, charts get data points extracted.
41
-
42
- Runs inside **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** (Anthropic's terminal assistant). One command. ~$0.50-$5 per document.
43
-
44
- Like [Landing AI's Agentic Document Extraction](https://landing.ai/agentic-document-extraction), but running locally via Claude Code.
45
-
46
- ---
47
-
48
- ## Before You Start
49
-
50
- You need two things:
51
-
52
- ### 1. Node.js
53
-
54
- Check if you have it:
55
-
56
- ```bash
57
- node --version
58
- ```
59
-
60
- If you see a version number, you're good. If you see "command not found", download Node.js from **[nodejs.org](https://nodejs.org/)** and install it.
61
-
62
- ### 2. Anthropic API Key or Pro/Max Plan
63
-
64
- You need one of these to use Claude Code:
65
-
66
- - **API key:** Get one at **[console.anthropic.com](https://console.anthropic.com/)**. Requires a payment method.
67
- - **Pro or Max plan:** If you subscribe to Claude Pro ($20/mo) or Max ($100/mo), you can use Claude Code without a separate API key.
68
-
69
16
  ---
70
17
 
71
- ## Setup (5 minutes)
72
-
73
- ### Step 1: Open your terminal
18
+ ## Requirements
74
19
 
75
- **Mac:** Press `Cmd + Space`, type `Terminal`, press Enter
76
-
77
- **Windows:** Press `Win + X`, click "Terminal" or "PowerShell"
78
-
79
- **Linux:** Press `Ctrl + Alt + T`
20
+ - **Node.js** - [nodejs.org](https://nodejs.org/)
21
+ - **Claude Code** - Requires API key or Pro/Max subscription
80
22
 
81
23
  ---
82
24
 
83
- ### Step 2: Install Claude Code
25
+ ## Install
84
26
 
85
- Copy this command and paste it into your terminal:
27
+ ### Step 1: Install Claude Code
86
28
 
87
29
  ```bash
88
30
  npm install -g @anthropic-ai/claude-code
@@ -92,13 +34,7 @@ npm install -g @anthropic-ai/claude-code
92
34
  <img src="assets/screenshots/step0.png" alt="Install Claude Code" width="550">
93
35
  </p>
94
36
 
95
- Wait for it to finish.
96
-
97
- ---
98
-
99
- ### Step 3: Install structurecc
100
-
101
- Copy and run this:
37
+ ### Step 2: Install structurecc
102
38
 
103
39
  ```bash
104
40
  npx structurecc
@@ -108,34 +44,9 @@ npx structurecc
108
44
  <img src="assets/screenshots/step1.png" alt="Install structurecc" width="420">
109
45
  </p>
110
46
 
111
- You will see a STRUCTURE banner. That means it worked. You only do this once.
112
-
113
- ---
114
-
115
- ### Step 4: Set up your document folder
47
+ ### Step 3: Start Claude Code
116
48
 
117
- Create a folder with your document:
118
-
119
- <p align="center">
120
- <img src="assets/screenshots/step2.png" alt="Folder structure" width="380">
121
- </p>
122
-
123
- ```
124
- documents/
125
- ├── document.pdf ← your PDF, DOCX, or image
126
- └── images/ ← extracted images go here (created automatically)
127
- ├── figure_1.png
128
- ├── table_2.png
129
- └── chart_3.png
130
- ```
131
-
132
- **Put your document in a folder. That's it.**
133
-
134
- ---
135
-
136
- ### Step 5: Open Claude Code
137
-
138
- Navigate to your document folder and start Claude Code:
49
+ Navigate to your document folder and run:
139
50
 
140
51
  ```bash
141
52
  cd ~/Desktop/documents
@@ -146,131 +57,40 @@ claude
146
57
  <img src="assets/screenshots/step3a.png" alt="Start Claude Code" width="460">
147
58
  </p>
148
59
 
149
- **Windows users:** Replace `~/Desktop/documents` with your actual path, like `C:\Users\YourName\Desktop\documents`
150
-
151
- The first time you run `claude`, it will ask for your API key. Paste it in.
60
+ ### Step 4: Run structure
152
61
 
153
- ---
154
-
155
- ### Step 6: Run structure
156
-
157
- Now you are inside Claude Code. Type this command:
62
+ Inside Claude Code:
158
63
 
159
64
  ```
160
65
  /structure document.pdf
161
66
  ```
162
67
 
163
68
  <p align="center">
164
- <img src="assets/screenshots/step3.png" alt="Run /structure" width="500">
69
+ <img src="assets/screenshots/step3.png" alt="Run /structure" width="520">
165
70
  </p>
166
71
 
167
- **Important:** The `/structure` command only works inside Claude Code. If you type it in your regular terminal, it will not work.
168
-
169
- structurecc will:
170
- 1. Extract every image from your document
171
- 2. Spawn one agent per image (all running in parallel)
172
- 3. Each agent exhaustively analyzes its visual element
173
- 4. Combine everything into `STRUCTURED.md`
72
+ Supports **PDF**, **DOCX**, **PNG**, **JPG**, and **TIFF**.
174
73
 
175
74
  ---
176
75
 
177
- ## What You Get
178
-
179
- A comprehensive markdown file with every visual element extracted:
76
+ ## Output
180
77
 
181
78
  ```
182
79
  document_extracted/
183
- ├── images/ # All extracted visuals
184
- ├── elements/ # One markdown file per element
185
- │ ├── element_1.md # Table fully extracted
186
- │ ├── element_2.md # Figure analyzed
187
- │ └── ...
188
- └── STRUCTURED.md # Everything combined
189
- ```
190
-
191
- ### Example: Table Extraction
192
-
193
- ```markdown
194
- # Patient Demographics
195
-
196
- **Type:** Table
197
- **Source:** Page 3, clinical_trial.pdf
198
-
199
- ## Content
200
-
201
- | Group | N | Age (mean±SD) | Male (%) |
202
- |-------|---|---------------|----------|
203
- | Treatment | 245 | 54.3±12.1 | 58.4 |
204
- | Placebo | 248 | 53.8±11.9 | 56.9 |
205
- | p-value | - | 0.67 | 0.73 |
206
-
207
- ## Notes
208
- - Confidence level: High
209
- - * Missing data excluded from analysis
80
+ ├── images/ # Extracted visuals
81
+ ├── elements/ # Markdown per element
82
+ └── STRUCTURED.md # Combined output
210
83
  ```
211
84
 
212
- ### Example: Chart Analysis
213
-
214
- ```markdown
215
- # Kaplan-Meier Survival Curves
216
-
217
- **Type:** Chart (Line/Survival)
218
- **Source:** Page 7, clinical_trial.pdf
219
-
220
- ## Content
221
-
222
- Survival curves comparing treatment (blue) vs placebo (red) over 24 months.
223
-
224
- Key data points:
225
- - 12-month survival: Treatment 0.89, Placebo 0.78
226
- - 24-month survival: Treatment 0.76, Placebo 0.61
227
- - Log-rank p = 0.003
228
-
229
- ## Labels & Annotations
230
- - Y-axis: "Survival Probability"
231
- - X-axis: "Time (months)"
232
- - Legend: "Treatment (n=245)", "Placebo (n=248)"
233
- ```
234
-
235
- ---
236
-
237
- ## Cost
238
-
239
- | Document | Elements | ~Cost |
240
- |----------|----------|-------|
241
- | Simple paper | 5-10 | $0.50-$1 |
242
- | Full paper | 15-25 | $2-$4 |
243
- | Dense report | 40+ | $5-$10 |
244
-
245
- Uses Claude's multimodal vision. Works best with **Opus 4.5** for complex tables and charts.
246
-
247
- ---
248
-
249
- ## Supported Formats
250
-
251
- - **PDF** - Extracts embedded images via PyMuPDF
252
- - **DOCX** - Extracts images from Word's media folder
253
- - **PNG/JPG/TIFF** - Analyzes images directly
254
-
255
85
  ---
256
86
 
257
87
  ## Troubleshooting
258
88
 
259
- **"npm: command not found"**
260
-
261
- You need Node.js. Download it from [nodejs.org](https://nodejs.org/).
262
-
263
- **"bash: /structure: No such file or directory"**
264
-
265
- You typed `/structure` in your regular terminal. You need to type it inside Claude Code. First run `claude` to start Claude Code, then type `/structure`.
266
-
267
- **"No images found"**
268
-
269
- Make sure your PDF contains actual images, not just text. Some PDFs render everything as text.
270
-
271
- **Claude Code asks for an API key**
272
-
273
- Either get an API key at [console.anthropic.com](https://console.anthropic.com/), or subscribe to Claude Pro/Max at [claude.ai](https://claude.ai/).
89
+ | Issue | Solution |
90
+ |-------|----------|
91
+ | `npm: command not found` | Install Node.js from [nodejs.org](https://nodejs.org/) |
92
+ | `/structure: No such file` | Run `claude` first, then type `/structure` inside Claude Code |
93
+ | No images found | PDF may be text-only with no embedded images |
274
94
 
275
95
  ---
276
96
 
@@ -285,9 +105,3 @@ npx structurecc --uninstall
285
105
  ## License
286
106
 
287
107
  MIT
288
-
289
- ---
290
-
291
- <p align="center">
292
- <strong>Unstructured in. Structured out.</strong>
293
- </p>
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: structurecc-classifier
3
+ description: Phase 1 - Classify visual elements for specialized extraction
4
+ ---
5
+
6
+ # Visual Element Classifier
7
+
8
+ You are a rapid visual classifier. Your ONLY job is to identify what type of visual element an image contains so the correct specialized extractor can be dispatched.
9
+
10
+ ## Classification Task
11
+
12
+ Given an image, output a JSON classification. Nothing else.
13
+
14
+ ## Classification Types
15
+
16
+ | Type | Description |
17
+ |------|-------------|
18
+ | `table_simple` | Standard grid table with clear rows/columns, no merged cells |
19
+ | `table_complex` | Table with merged cells, nested headers, or irregular structure |
20
+ | `chart_kaplan_meier` | Survival curves / time-to-event plots with step functions |
21
+ | `chart_bar` | Bar charts (horizontal or vertical), grouped or stacked |
22
+ | `chart_line` | Line graphs showing trends over continuous x-axis |
23
+ | `chart_scatter` | Scatter plots with individual data points |
24
+ | `chart_box` | Box plots / whisker plots showing distributions |
25
+ | `chart_pie` | Pie charts or donut charts |
26
+ | `chart_area` | Area charts (filled line charts) |
27
+ | `chart_forest` | Forest plots (meta-analysis results) |
28
+ | `chart_volcano` | Volcano plots (differential expression) |
29
+ | `heatmap` | Color-coded matrix (correlation, expression, etc.) |
30
+ | `diagram_flowchart` | Process flows with boxes and arrows |
31
+ | `diagram_timeline` | Temporal sequences, study timelines, CONSORT diagrams |
32
+ | `diagram_network` | Network graphs, pathway diagrams, interaction maps |
33
+ | `diagram_schematic` | Technical schematics, anatomical diagrams |
34
+ | `diagram_venn` | Venn diagrams showing set overlaps |
35
+ | `multi_panel` | Composite figure with labeled panels (A, B, C, D) |
36
+ | `photograph` | Real-world photographs, microscopy images, scans |
37
+ | `equation` | Mathematical equations, formulas |
38
+ | `text_block` | Text-heavy image, caption, or label |
39
+ | `unknown` | Cannot confidently classify |
40
+
41
+ ## Output Format
42
+
43
+ Return ONLY valid JSON:
44
+
45
+ ```json
46
+ {
47
+ "classification": {
48
+ "primary_type": "chart_kaplan_meier",
49
+ "confidence": 0.95,
50
+ "secondary_type": null,
51
+ "is_multi_panel": false,
52
+ "panel_count": 1,
53
+ "contains_table": false,
54
+ "contains_text_annotations": true
55
+ },
56
+ "routing": {
57
+ "extractor": "structurecc-extract-chart",
58
+ "extraction_hints": ["survival_curve", "two_groups", "has_risk_table"]
59
+ }
60
+ }
61
+ ```
62
+
63
+ ## Field Definitions
64
+
65
+ ### classification
66
+ - `primary_type`: Main visual type from the table above
67
+ - `confidence`: 0.0-1.0 confidence in classification
68
+ - `secondary_type`: If image contains a secondary element (e.g., chart with embedded table)
69
+ - `is_multi_panel`: True if figure has labeled sub-panels (A, B, C...)
70
+ - `panel_count`: Number of panels if multi-panel
71
+ - `contains_table`: True if any tabular data is present
72
+ - `contains_text_annotations`: True if significant text labels/annotations present
73
+
74
+ ### routing
75
+ - `extractor`: Which specialized extractor to use
76
+ - `extraction_hints`: List of specific features to watch for
77
+
78
+ ## Extractor Routing
79
+
80
+ | Primary Type | Extractor |
81
+ |--------------|-----------|
82
+ | `table_simple`, `table_complex` | `structurecc-extract-table` |
83
+ | `chart_*` | `structurecc-extract-chart` |
84
+ | `heatmap` | `structurecc-extract-heatmap` |
85
+ | `diagram_*` | `structurecc-extract-diagram` |
86
+ | `multi_panel` | `structurecc-extract-multipanel` |
87
+ | `photograph`, `equation`, `text_block`, `unknown` | `structurecc-extract-generic` |
88
+
89
+ ## Rules
90
+
91
+ 1. **Be fast** - This is a triage step, not deep analysis
92
+ 2. **Be decisive** - Pick the best match, use confidence to express uncertainty
93
+ 3. **Detect multi-panel** - If you see A, B, C, D labels, set `is_multi_panel: true`
94
+ 4. **Note secondary elements** - Charts often have risk tables, legends, etc.
95
+ 5. **Output ONLY JSON** - No explanations, no markdown, just the JSON object
96
+
97
+ ## Examples
98
+
99
+ **Kaplan-Meier curve with risk table below:**
100
+ ```json
101
+ {
102
+ "classification": {
103
+ "primary_type": "chart_kaplan_meier",
104
+ "confidence": 0.98,
105
+ "secondary_type": "table_simple",
106
+ "is_multi_panel": false,
107
+ "panel_count": 1,
108
+ "contains_table": true,
109
+ "contains_text_annotations": true
110
+ },
111
+ "routing": {
112
+ "extractor": "structurecc-extract-chart",
113
+ "extraction_hints": ["survival_curve", "has_risk_table", "has_confidence_intervals"]
114
+ }
115
+ }
116
+ ```
117
+
118
+ **Four-panel figure with A=bar chart, B=heatmap, C=box plot, D=table:**
119
+ ```json
120
+ {
121
+ "classification": {
122
+ "primary_type": "multi_panel",
123
+ "confidence": 0.99,
124
+ "secondary_type": null,
125
+ "is_multi_panel": true,
126
+ "panel_count": 4,
127
+ "contains_table": true,
128
+ "contains_text_annotations": true
129
+ },
130
+ "routing": {
131
+ "extractor": "structurecc-extract-multipanel",
132
+ "extraction_hints": ["panel_A_bar", "panel_B_heatmap", "panel_C_boxplot", "panel_D_table"]
133
+ }
134
+ }
135
+ ```