feat: add preprocessing module for BOM condition transformation
All checks were successful
NTFY Notification / notify (push) Successful in 5s
All checks were successful
NTFY Notification / notify (push) Successful in 5s
Add M05_PreProcessor module to handle value mapping and condition simplification for "接头" category before parsing. Features: - Value mapping: azxs codes (A0/AT/AH→径向, B0/BT/BZ/BH→下轴向, Z0/ZT/ZZ/ZH→中轴向) and lcfw ranges (M01-M11→低压, M12-M16→高压) - OR condition merging: automatically removes duplicate OR segments - Smart parentheses handling: removes parentheses for single atoms, preserves them when needed for logical structure - Recursive nested expression processing - Graceful degradation when "对照表" worksheet is missing Integration: - Modified M01_Main to initialize preprocessor after M03_Logic - Preprocessing applied only for "接头" category - Updated M99_TestRunner with 8 comprehensive test cases - All tests passing (50 total: 42 core + 8 preprocessing) Documentation: - Added detailed flow documentation for Test_PP_06_FullIntegration with mermaid diagrams in docs/Test_PP_06_FullIntegration_流程详解.md - Updated CLAUDE.md with preprocessing module description and documentation guidelines (docs/ vs reference_docs/) Example transformation: Input: gclj=M16 AND (azxs=A0 OR azxs=AT) AND (lcfw=M01 OR lcfw=M15) Output: gclj=M16 AND azxs=径向 AND (lcfw=低压 OR lcfw=高压) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
85
CLAUDE.md
85
CLAUDE.md
@@ -16,6 +16,7 @@ The system follows a modular architecture with clear separation of concerns:
|
||||
- **M02_DataIO.bas** - Data input/output operations. Reads source data from "平台配置清单" worksheet and generates categorized output workbooks.
|
||||
- **M03_Logic.bas** - Core recursive parser for conditional expressions. Handles logical operators (AND/OR), nested parentheses, and key=value/key!=val conditions. Implements Cartesian products for set operations.
|
||||
- **M04_Config.bas** - Column mapping and header priorities. Defines source data columns (CODE, NAME, QTY, CONDITION, CATEGORY) and standard ordering for output.
|
||||
- **M05_PreProcessor.bas** - Preprocessing module for condition transformation. Handles value mapping for "接头" category (e.g., azxs=A0→径向, lcfw=M01→低压), duplicate OR condition merging, and nested expression simplification. Uses mapping data from "对照表" worksheet.
|
||||
- **M99_TestRunner.bas** - Unit testing framework. Run `RunAllTests()` in VBA Immediate window to execute tests.
|
||||
|
||||
### Class Module
|
||||
@@ -26,12 +27,37 @@ The system follows a modular architecture with clear separation of concerns:
|
||||
|
||||
```
|
||||
Excel "平台配置清单" → M01_Main → M02_DataIO.LoadSourceData() →
|
||||
M03_Logic.ParseExpression() → Category Dictionary →
|
||||
M02_DataIO.CreateOutputWorkbook() → New Excel Workbook + Error Report
|
||||
M05_PreProcessor.PreprocessCondition() → M03_Logic.ParseRule() →
|
||||
Category Dictionary → M02_DataIO.CreateOutputWorkbook() →
|
||||
New Excel Workbook + Error Report
|
||||
```
|
||||
|
||||
## Key Concepts
|
||||
|
||||
### Preprocessing (M05_PreProcessor)
|
||||
|
||||
Before parsing conditions, the system applies preprocessing for "接头" (joint) category:
|
||||
|
||||
**Value Mapping**:
|
||||
- **azxs** (安装形式): Maps codes to descriptive values
|
||||
- A0, AT, AH → 径向
|
||||
- B0, BT, BZ, BH → 下轴向
|
||||
- Z0, ZT, ZZ, ZH → 中轴向
|
||||
- **lcfw** (量程范围): Maps range codes to categories
|
||||
- M01-M11 → 低压
|
||||
- M12-M16 → 高压
|
||||
|
||||
**OR Condition Merging**:
|
||||
- Duplicate OR conditions are automatically merged
|
||||
- Example: `azxs=径向 OR azxs=径向` → `azxs=径向`
|
||||
- Different values preserve OR structure: `lcfw=低压 OR lcfw=高压`
|
||||
|
||||
**Parentheses Handling**:
|
||||
- Simplified single-value expressions: `(azxs=A0 OR azxs=AT)` → `azxs=径向`
|
||||
- Preserves parentheses when needed: `(lcfw=M01 OR lcfw=M15)` → `(lcfw=低压 OR lcfw=高压)`
|
||||
|
||||
Mapping data is loaded from "对照表" worksheet (columns A:B for lcfw, D:E for azxs).
|
||||
|
||||
### Conditional Logic Syntax
|
||||
|
||||
Conditions use a specific syntax for product selection:
|
||||
@@ -78,6 +104,14 @@ This runs unit tests for:
|
||||
- OR operations with union operations
|
||||
- Nested parentheses handling
|
||||
- Logic conflict detection
|
||||
- **Preprocessing tests** (Test_PP_01 to Test_PP_08):
|
||||
- azxs mapping load (12 values)
|
||||
- lcfw mapping load (M01-M16)
|
||||
- Value replacement
|
||||
- OR condition merging
|
||||
- Full integration with M03_Logic
|
||||
- Non-"接头" category handling
|
||||
- Unmapped value handling
|
||||
|
||||
### Python Skills (Claude Code Integration)
|
||||
|
||||
@@ -143,7 +177,9 @@ AutoBOM/
|
||||
│ └── ClassModules/ # OOP components (clsErrorLogger)
|
||||
├── .claude/
|
||||
│ └── skills/ # Claude Code integration skills
|
||||
├── reference_docs/ # Documentation and examples
|
||||
├── docs/ # Code-related documentation
|
||||
│ └── Test_PP_06_FullIntegration_流程详解.md
|
||||
├── reference_docs/ # Business-related documentation and examples
|
||||
└── YTHN-100.xlsm/.xlsx # Main workbook files
|
||||
```
|
||||
|
||||
@@ -160,3 +196,46 @@ The system uses `clsErrorLogger` for comprehensive error tracking:
|
||||
- **Operator Precedence**: AND is processed before OR, parentheses override default precedence
|
||||
- **Recursive Parsing**: Nested expressions are handled recursively in M03_Logic
|
||||
- **Dynamic Columns**: Output workbooks detect and include only relevant configuration keys
|
||||
|
||||
## Documentation Guidelines
|
||||
|
||||
### Document Storage Policy
|
||||
|
||||
When creating documentation for this project, follow these guidelines:
|
||||
|
||||
**Code-Related Documentation** → Save in `docs/` directory:
|
||||
- Technical specifications
|
||||
- Algorithm explanations
|
||||
- Code flow diagrams
|
||||
- Test documentation
|
||||
- API/reference documentation for code modules
|
||||
- Implementation guides
|
||||
|
||||
Examples:
|
||||
- `docs/Test_PP_06_FullIntegration_流程详解.md` ✓
|
||||
- `docs/M03_Logic_Algorithm.md` ✓
|
||||
- `docs/API_Reference.md` ✓
|
||||
|
||||
**Business-Related Documentation** → Save in `reference_docs/` directory:
|
||||
- Business requirements
|
||||
- User manuals
|
||||
- Product specifications
|
||||
- Industry standards
|
||||
- Configuration examples
|
||||
- Business process documentation
|
||||
|
||||
Examples:
|
||||
- `reference_docs/BOM_Requirements.md` ✓
|
||||
- `reference_docs/Product_Catalog.xlsx` ✓
|
||||
- `reference_docs/User_Guide.pdf` ✓
|
||||
|
||||
**Decision Tree**:
|
||||
```
|
||||
Is it about code implementation or technical details?
|
||||
├─ Yes → docs/
|
||||
└─ No → Is it about business logic or user-facing content?
|
||||
├─ Yes → reference_docs/
|
||||
└─ No → Ask for clarification
|
||||
```
|
||||
|
||||
**Note**: When in doubt, prefer `docs/` for technical content and `reference_docs/` for business content.
|
||||
|
||||
Reference in New Issue
Block a user