fix:characters
Comprehensive character data fixes that run in the correct dependency order to ensure data consistency.
Overview
This command performs all character maintenance tasks in a single, logical workflow:
NULL Assignments: Assigns dialogue lines with NULL character_id to narrator characters
Special Assignments: Fixes 'extend' and 'centered' character assignments to previous line's character
Statistics: Recalculates character and language statistics from dialogue lines
Version References: Updates first_seen/last_seen versions, creates missing stats, deletes orphaned characters
Data Completeness Protection: Only versions with full dialogue line details will have statistics updated. This protects versions with incomplete data (e.g., Godot games with language totals only).
Data Completeness Levels
The system recognizes four levels of data completeness:
Full Detail: Has individual dialogue lines with text content - Safe to update
Character Stats: Has character-level statistics but no individual lines - Protected from updates
Language Only: Has only language-level totals - Protected from updates
No Detail: Has only basic version info - Protected from updates
Only versions with "Full Detail" level will have their character statistics recalculated.
Usage
Basic Usage
Step-by-Step Execution
Targeted Processing
Options
Option | Description |
---|---|
| Process only the specified game |
| Process only the specified version (overrides --game-id) |
| Run only a specific step (null-assignments\|special-assignments\|stats\|version-references) |
| Show what would be done without making changes |
| Process only a specific special character (extend, centered) |
Detailed Process
Step 1: NULL Assignments
Purpose: Assign dialogue lines with NULL character_id to narrator characters
Actions:
Finds all dialogue lines with NULL character_id
Creates narrator characters for games that don't have them
Assigns all NULL lines to the appropriate narrator character
Reports lines updated and narrator characters created
When to use: Always run first, or when you notice dialogue lines without character assignments
Step 2: Special Assignments
Purpose: Fix special character assignments that should belong to previous line's character
Actions:
Processes 'extend' and 'centered' characters
Finds the previous dialogue line in the same file
Reassigns special character lines to the previous line's character
Reports lines reassigned and versions processed
Special Characters Handled:
extend
- Continuation of previous character's dialoguecentered
- Centered text that should belong to previous character
Step 3: Statistics
Purpose: Recalculate character and language statistics from dialogue lines
Actions:
Recalculates blocks and words for characters with issues (narrator + zero stats)
Uses sophisticated SQL that matches Python's text.split() behavior
Automatically recalculates language totals to ensure consistency
Respects data completeness protection
Language Totals: When character statistics are recalculated, the corresponding language-level totals are automatically updated to ensure consistency between character breakdowns and language totals.
Step 4: Version References
Purpose: Update version tracking and cleanup orphaned data
Actions:
Updates first_seen_in_version_id and last_seen_in_version_id for characters
Creates missing version_character_stats entries for characters in dialogue
Deletes orphaned characters that have no dialogue lines
Reports characters updated, stats created, and characters deleted
Output Example
Best Practices
Run with --dry-run first to preview changes
Process specific games during development/testing
Use individual steps when you only need specific fixes
Monitor the logs for data completeness protection warnings
Run after importing new game versions to ensure consistency
Error Handling
The command includes comprehensive error handling:
Data completeness protection prevents corruption of incomplete data
Individual step failures don't stop the entire process
Detailed logging shows what was skipped and why
Dry-run mode allows safe previewing of all changes