This system automatically updates financial documents by matching and replacing numerical values between Excel spreadsheets and Word documents. It uses exact text matching and LLM-based verification to ensure accurate updates while maintaining document structure.
-
Document Processing
- Excel Parser (
funnels/excel_utils.py): Maps cells to headers - Word Parser (
funnels/extract.py): Extracts sentences with context - Processor (
utils/document_processing/processor.py): Orchestrates matching and updates
- Excel Parser (
-
LLM Integration
- Multiple Provider Support:
- Claude (Anthropic)
- Qwen (Default)
- Configurable timeout and model settings
- Handles text analysis and verification
- Multiple Provider Support:
-
Web Interface
- Flask-based web application
- File upload/download functionality
- Real-time processing status
- Results visualization with confidence scores
-
Data Loading
- Excel Parser: Maps each cell to its row and column headers
- Document Parser: Extracts sentences from Word documents
-
Matching Process
- Finds exact text matches between Excel headers and document sentences
- No assumptions made about text content or structure
-
Value Updates
- Uses LLM to update matched sentences
- Preserves original sentence structure and formatting
- Only updates numerical values
-
Confidence Scoring Base confidence of 0.7 for exact matches, with additional factors:
- Length ratio (0-0.15): Longer matches relative to sentence length
- Position score (0-0.15): Earlier matches in sentence weighted higher
- Update success (0-0.1): Ratio of successfully updated values
- Multiple match penalty: -0.1 per additional match
pip install -r requirements.txtSet up environment variables:
LLM_PROVIDER=qwen # or claude
QWEN_API_KEY=sk-xxx # Your API key
CLAUDE_API_KEY=sk-xxx # Your API keypython main.py <docx_file> <excel_file>Or use the web interface:
python app.py # Starts server on port 8080python app.py # Starts server on port 8080python api.py # Starts server on port 8080POST /run-syncspace/
Files:
- docx_file: Word document (.docx)
- excel_file: Excel spreadsheet (.xlsx)
GET /download
Response: Updated .docx file
funnels/excel_utils.py: Excel file parsingfunnels/extract.py: Word document text extractionutils/document_processing/processor.py: Main processing logic
app.py: Flask web applicationtemplates/index.html: Upload interface
config/: Configuration managementutils/llm.py: LLM integrationutils/logging.py: Logging setup
- Size limit: 16MB per file
- Supported formats: .docx, .xlsx only
- Automatic cleanup of temporary files
- LLM timeout: 30 seconds default
Use eval/evaluate_accuracy.py to measure:
- Precision: Correct updates / Total updates
- Recall: Found changes / Actual changes
- F1 Score: Harmonic mean of precision and recall
api.py: FastAPI server for REST APIapp.py: Flask server for web interfacemain.py: Main processing logicutils/: Utility functions and configurationtemplates/: HTML templates for web interfacestatic/: Static files for web interface