https://github.com/hydroroll-team/conventional_role_play
结构化任何文本(大到指令解析, 小到 RolePlay 文案与跑团日志), 并提供规则匹配, 获取任何数据 | Structure any text (from large-scale instruction parsing to small-scale role-playing game scripts and session logs), and provide rule matching to extract any data
https://github.com/hydroroll-team/conventional_role_play
ai classification dice hydroroll lac ner nlp re roll
Last synced: 4 months ago
JSON representation
结构化任何文本(大到指令解析, 小到 RolePlay 文案与跑团日志), 并提供规则匹配, 获取任何数据 | Structure any text (from large-scale instruction parsing to small-scale role-playing game scripts and session logs), and provide rule matching to extract any data
- Host: GitHub
- URL: https://github.com/hydroroll-team/conventional_role_play
- Owner: HydroRoll-Team
- License: agpl-3.0
- Created: 2025-03-12T13:32:28.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-03T00:40:16.000Z (5 months ago)
- Last Synced: 2026-02-03T14:02:55.739Z (5 months ago)
- Topics: ai, classification, dice, hydroroll, lac, ner, nlp, re, roll
- Language: Python
- Homepage: https://cvrp.hydroroll.team
- Size: 435 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Conventional Role Play
## Overview
Conventional Role Play (CVRP) is a Python SDK designed for structured processing of tabletop role-playing game (TRPG) logs. It provides functionalities for parsing logs, extracting rules, and rendering outputs in multiple formats. This SDK aims to streamline the analysis and presentation of TRPG session data.
> **Note**
> This documentation is still under construction. Contributions are welcome! See contributing for more information.
## Key Features
* **Rule Extraction**: Easily extract rules from JSON configuration files using the `RuleExtractor` class.
* **Multi-format Rendering**: Render outputs in various formats such as HTML, Markdown, and JSON using the respective renderer classes (e.g., `HTMLRenderer`).
* **THULAC Smart Parser**: Intelligent parsing using Tsinghua THULAC (THU Lexical Analyzer for Chinese) for automatic content recognition with minimal configuration. See [THULAC Parser Documentation](docs/THULAC_PARSER.md).
* **Extensibility**: Create custom plugins to extend the functionality of the SDK. See custom-plugins for details.
* **Comprehensive API**: Full API documentation available for all modules and classes. See api-documentation.
## Installation
To install Conventional Role Play, you can use uv or pip:
```bash
uv add conventionalrp
```
## Basic Usage
### Traditional Parser (Regex-based)
Here is a simple example of how to use the TRPG Log Processor:
```python
from conventionalrp.core.parser import Parser
from conventionalrp.core.processor import Processor
from conventionalrp.extractors.rule_extractor import RuleExtractor
from conventionalrp.renderers.html_renderer import HTMLRenderer
# Step 1: Load rules
rule_extractor = RuleExtractor()
rules = rule_extractor.load_rules('path/to/rules.json')
# Step 2: Parse the log
parser = Parser(rules)
parsed_log = parser.parse_log('path/to/log.txt')
# Step 3: Process the parsed tokens
processor = Processor()
output = processor.process_tokens(parsed_log)
# Step 4: Render the output
renderer = HTMLRenderer()
html_output = renderer.render(output)
# Save or display the output
with open('output.html', 'w') as f:
f.write(html_output)
```
### THULAC Smart Parser
Simplified parsing with automatic content recognition:
```python
from conventionalrp.core.thulac_parser import THULACParser
# Step 1: Create parser
parser = THULACParser(seg_only=False)
# Step 2: Load simplified rules (just delimiters!)
parser.load_rules('examples/rules/thulac_rules.json5')
# Step 3: Parse a line
text = '[15:30] "Hello!"(waves)'
result = parser.parse_line(text)
# Result:
# {
# "metadata": {"timestamp": "15:30", "speaker": "Alice"},
# "content": [
# {"type": "dialogue", "content": "Hello!", "confidence": 1.0},
# {"type": "action", "content": "waves", "confidence": 1.0}
# ]
# }
# Step 4: Parse entire log file
results = parser.parse_log('path/to/log.txt')
stats = parser.get_statistics()
print(f"Parsed {stats['total_parsed']} lines")
```
## Custom Plugins
To create a custom plugin, you can follow the example provided in
custom_plugin.py
. This allows you to add additional processing or rendering capabilities tailored to your needs.
## API Documentation
For more detailed information on the API and available classes, please refer to the [API documentation](https://crp.hydroroll.team/api.html).
## License
This project is licensed under the AGPLv3.0 License - see the
LICENSE
file for details.
## Project Links
* [Homepage](https://hydroroll.team/)
* [Documentation](https://crp.hydroroll.team/)
* [GitHub Repository](https://github.com/HydroRoll-Team/conventional_role_play)