data-structures
Understand data structures in the GCACW parser pipeline (raw tables, parsed units, web JSON). Use when debugging data issues, understanding field mappings between stages, checking column configurations, or investigating why units are missing or malformed. Includes inspection utilities (inspect_raw.py, inspect_parsed.py, compare_data.py). Essential for work involving raw_table_extractor.py, parse_raw_tables.py, convert_to_web.py, or game_configs.json.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Data Structures
Documentation for the three-stage data pipeline used by the GCACW scenario parser.
Pipeline Overview
PDF → raw_table_extractor.py → raw/{game}_raw_tables.json (snake_case)
↓
parse_raw_tables.py → parsed/{game}_parsed.json (snake_case)
↓
convert_to_web.py → web/public/data/{game}.json (camelCase)
When to Use This Skill
Use this skill when:
- Debugging missing or malformed units in any stage
- Understanding field mappings between pipeline stages
- Investigating column configuration issues in
game_configs.json - Comparing data between stages to isolate parsing problems
- Working with raw table extraction, parsing, or web conversion
Quick Reference
Stage 1: Raw Tables
File: raw/{game}_raw_tables.json
Source: raw_table_extractor.py
Structure preserves PDF extraction exactly as read:
- Array of scenarios, each with
confederate_tablesandunion_tables - Each table has
header_row,rows[][], andannotations{} - Values are raw strings from PDF, may span multiple tokens
- Footnote symbols embedded in cell values (e.g.,
"2*")
Stage 2: Parsed Units
File: parsed/{game}_parsed.json
Source: parse_raw_tables.py
Structured unit objects with semantic fields:
-
unit_leader,size,command,unit_type,manpower_value,hex_location - Footnote symbols extracted to
notes[]array - Side assignment:
"Confederate"or"Union" - Optional:
turn,reinforcement_set,table_name
Stage 3: Web JSON
File: web/public/data/{game}.json
Source: convert_to_web.py
Frontend-ready format:
- CamelCase field names (
hexLocation,manpowerValue) - Gunboats/special units separated into
confederateGunboats/unionGunboats - Matches TypeScript interfaces in
web/src/types.ts
Inspection Tools
Three utility scripts help debug data at each stage:
# View raw table data
cd parser && uv run python utils/inspect_raw.py <game_id>
cd parser && uv run python utils/inspect_raw.py <game_id> --scenario 1 --table "Confederate Set-Up"
# View parsed units
cd parser && uv run python utils/inspect_parsed.py <game_id>
cd parser && uv run python utils/inspect_parsed.py <game_id> --scenario 1 --side Confederate
# Compare raw vs parsed (for debugging parsing issues)
cd parser && uv run python utils/compare_data.py <game_id> <scenario>
cd parser && uv run python utils/compare_data.py <game_id> <scenario> --side Union --table "Union Set-Up"
All scripts support --help for detailed usage.
Common Debugging Patterns
Missing Units in Parsed Data
- Check raw extraction:
uv run python inspect_raw.py <game> --scenario N - Look for the missing unit in raw table rows
- If present in raw but missing in parsed, check column config in
game_configs.json - If absent from raw, check PDF extraction with
utils/diagnose_pdf.py
Wrong Unit Attributes
- Compare raw vs parsed:
uv run python compare_data.py <game> <scenario> - Check column configuration in
game_configs.json - Verify column mappings match the raw
header_row
Footnotes Not Matching
- Check if symbol is in
footnote_symbolslist in config - Verify annotations dict in raw tables contains the symbol
- Check parser's footnote extraction logic
Field Naming Across Stages
| Concept | Raw | Parsed | Web JSON |
|---|---|---|---|
| Unit name | values[0...n] |
unit_leader |
name |
| Manpower | values[n] |
manpower_value |
manpowerValue |
| Hex | values[n] |
hex_location |
hexLocation |
| Type | values[n] |
unit_type |
type |
Detailed Documentation
For complete structure details, examples, and edge cases, see references/structures.md.
That file contains:
- Full JSON schemas for each stage
- Field-by-field descriptions
- TypeScript interface definitions
- Data flow examples
- Unit type explanations (Ldr, Inf, Cav, Art, Special)
- Size hierarchy (Army > Corps > Div > Brig > Regt)
- Hex location formats
- Footnote symbol reference
- Common patterns and edge cases
Related Files
- game_configs.json - Column mappings and parsing rules
- raw_table_extractor.py - Stage 1: PDF → raw
- parse_raw_tables.py - Stage 2: raw → parsed
- convert_to_web.py - Stage 3: parsed → web
- types.ts - TypeScript interfaces
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!