diff options
| author | 2025-10-24 23:15:35 +0800 | |
|---|---|---|
| committer | 2025-10-24 23:15:35 +0800 | |
| commit | 08299b37dfda86e56e4f2b442f68ccd2da7a82e3 (patch) | |
| tree | e155d11412a26f692d08b8eb796fa689fc5a4019 /examples/rules | |
| parent | 990048eb2163127615de60d9359c150bdfb99536 (diff) | |
| download | conventional_role_play-08299b37dfda86e56e4f2b442f68ccd2da7a82e3.tar.gz conventional_role_play-08299b37dfda86e56e4f2b442f68ccd2da7a82e3.zip | |
feat: Enhance Processor, RuleExtractor, and Renderers with type hints and improved documentation
- Added type hints to Processor methods for better clarity and type safety.
- Improved documentation for Processor methods, including detailed descriptions of parameters and return types.
- Refactored RuleExtractor to support optional configuration file loading and added error handling for file operations.
- Enhanced MarkdownRenderer to handle both list and dictionary inputs, with improved rendering logic.
- Created comprehensive examples and tests for all components, ensuring robust functionality and error handling.
- Added example rules for D&D 5E and structured output files for various formats (JSON, HTML, Markdown).
- Established a testing framework with clear instructions and coverage reporting.
Diffstat (limited to 'examples/rules')
| -rw-r--r-- | examples/rules/dnd5e_rules.json5 | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/examples/rules/dnd5e_rules.json5 b/examples/rules/dnd5e_rules.json5 new file mode 100644 index 0000000..96f7cd1 --- /dev/null +++ b/examples/rules/dnd5e_rules.json5 @@ -0,0 +1,78 @@ +{ + // D&D 5E TRPG 日志解析规则 + metadata: [ + { + type: "metadata", + patterns: [ + "^\\[(.+?)\\]\\s*<(.+?)>\\s*(.*)$", // [时间] <角色名> 内容 + "^(.+?)\\s*\\|\\s*(.+?)\\s*:\\s*(.*)$" // 时间 | 角色名: 内容 + ], + groups: ["timestamp", "speaker", "content"], + priority: 100 + } + ], + + content: [ + { + type: "dice_roll", + match_type: "enclosed", + patterns: [ + "\\[d(\\d+)\\s*=\\s*(\\d+)\\]", // [d20 = 15] + "\\.r(\\d*)d(\\d+)(?:[+\\-](\\d+))?", // .r1d20+5 + "\\((\\d+)d(\\d+)(?:[+\\-](\\d+))?\\s*=\\s*(\\d+)\\)" // (1d20+5 = 18) + ], + groups: ["dice_type", "result"], + priority: 90 + }, + { + type: "action", + match_type: "enclosed", + patterns: [ + "\\*\\*(.+?)\\*\\*", // **动作** + "\\*(.+?)\\*" // *动作* + ], + groups: ["action_text"], + priority: 80 + }, + { + type: "ooc", + match_type: "enclosed", + patterns: [ + "\\(\\((.+?)\\)\\)", // ((OOC对话)) + "//(.+?)$" // //OOC注释 + ], + groups: ["ooc_text"], + priority: 70 + }, + { + type: "dialogue", + match_type: "enclosed", + patterns: [ + "「(.+?)」", + "\u201c(.+?)\u201d", + "\"(.+?)\"" + ], + groups: ["dialogue_text"], + priority: 60 + }, + { + type: "system", + match_type: "prefix", + patterns: [ + "^\\[系统\\](.+)", + "^\\[System\\](.+)" + ], + groups: ["system_message"], + priority: 50 + }, + { + type: "text", + match_type: "prefix", + patterns: [ + "^(.+)$" + ], + groups: ["text_content"], + priority: 1 + } + ] +} |
