Skip to main content

HydroRoll Conventional Role Play SDK

Project description

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.
  • 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 pip:

pip install conventionalrp

Basic Usage

Traditional Parser (Regex-based)

Here is a simple example of how to use the TRPG Log Processor:

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:

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] <Alice> "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.

License

This project is licensed under the AGPLv3.0 License - see the

LICENSE

file for details.

Project Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conventionalrp-1.2.0.tar.gz (132.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

conventionalrp-1.2.0-cp39-abi3-win_amd64.whl (770.6 kB view details)

Uploaded CPython 3.9+Windows x86-64

conventionalrp-1.2.0-cp39-abi3-win32.whl (699.6 kB view details)

Uploaded CPython 3.9+Windows x86

conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_armv7l.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (958.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

conventionalrp-1.2.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

conventionalrp-1.2.0-cp39-abi3-macosx_11_0_arm64.whl (886.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

conventionalrp-1.2.0-cp39-abi3-macosx_10_12_x86_64.whl (944.7 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file conventionalrp-1.2.0.tar.gz.

File metadata

  • Download URL: conventionalrp-1.2.0.tar.gz
  • Upload date:
  • Size: 132.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for conventionalrp-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9b2cc2c1a6f759c826b96e5dde43b9b326ad866095aa9e7177e0d4b1146f4986
MD5 e7917d55e2e418ada98e68c79ab152ff
BLAKE2b-256 0d58fe3057fcea0f95c3eeeddeb532dc09cbbab427061c3f8bfc646c51a27315

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1c3395103f4c38ebce36b4080e3820fdf238da0344c69505192b4268cac6e565
MD5 ea52aed80f6afe749c3b78533f1942a9
BLAKE2b-256 8430e364364f46802609bf42c7b5939cf4dc1bac0a9f8a9032d5013180b1695a

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-win32.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 cc001a2756072fe95ab5e7cdb137cd204c852f4c1635b4ae6ae93c513a2febc7
MD5 a607f7ac6d7c0a8dd66f085db1ad5344
BLAKE2b-256 7396a52a5b61e6451aa04159165d31b99a1f037a103698f8d75896acce3071c0

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e1feadcdc69019632fd67477839bbbe75efe2ca4ba56fec0dcc5da23b397f8f9
MD5 978285bf29180d0c0a6a9ea4362bbdee
BLAKE2b-256 b836fe93df26a4ab7c613980c4616d64f132c3e1a0554a2fc3e4ad80866159e1

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 825010dade17d7ea0b73e86524267fd94b91f9334bd328536270748660d3f162
MD5 e4a614a42420bd1c00a9f6d4705917db
BLAKE2b-256 033919c7ecb585298340957ada6c623f26ed9ac9a2ea1472a55b6d212d835d1b

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 c0df14a3ee131100a7d870e139299a3db5c67995b9822cdab62c2967792c67a3
MD5 5def2922f1722cfe9c8d6484649a40ea
BLAKE2b-256 475d752d58de67ca762d5525022360721294b0fcb7cc590565d1de1a09b0d225

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e5b3290df6fa5a3e840f400cd6882e2cae0444ed9b4be71058f3c483436b1968
MD5 d5d4b07ffdd43c38e718654e0ffb60ce
BLAKE2b-256 32cb4facf0788575ffc6f4f46c7b21a16e3c50cff20ae12409daa2d1ffa6dab0

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c9b7648fdb1827d5d29a138b631e12fdd04cd64876371b6592507735e92cbc19
MD5 b014a376d5c534c54f17e420ed5d7666
BLAKE2b-256 17fc7003acd55665f0807f1cd7bfe039d19a34768ace655b2a98bc5936e224c7

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 87d8bd55f02fb6706814b3f3d70126ebe258ac448944d971402976e1e5e3f774
MD5 0e6e59480f5d93fc19c569a578f5f730
BLAKE2b-256 6cec01712d0d1e86849381f531272c62a65e556f6dc51ac5d190b932edc4a793

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 1fe7ccd64cc85a1ee6a3b50ad6a1c20206d858b180199abfdd1cc3755efd9e19
MD5 2000f3b78f3b06605f88021f026725a0
BLAKE2b-256 d4daca3df63e9f7c1dfe64ec3e2ec120504affe17e8a04847d42827a21240531

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 5a8c6c3080266316d183807b982716025af687c19b0042cee5e46fcea1d0209f
MD5 7245619d52a581850cf9f19460898e8f
BLAKE2b-256 716dd39456da868b867d32e8d39da077d7c08ec2733f89e240ce7eabbf817ffe

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 083e6ee3b0924c17fc496a5056209011bd3c77e83186108f3802799a78a5a158
MD5 df8dc646b5d044d7ed30b9d3e6127cec
BLAKE2b-256 5892c18f18612156afbcd71d467bea3f0be4c0c28926039b338ad08c0a5ce333

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 741946103440810d7c8984e7dbf9679350a9e5b4e89d5092c769a4ee8b7b83c1
MD5 86dfa0ee12fe789a6537ab197fb6f140
BLAKE2b-256 7813198f6fc2136ad3c86d0bd77ce51f111d6c1ae7a4f03168d553678b971801

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8ffcfd88bb44db88fffcaee72a166be4ffebb6225d6964a9c2e7ded2e6d31e9
MD5 321cdf97e5562457f940ccc1847362fc
BLAKE2b-256 0a2e0ab402986d8c1098f408e2d68e8274f23c8ea6b04043da87262c28579d94

See more details on using hashes here.

File details

Details for the file conventionalrp-1.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for conventionalrp-1.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6a84ac171e7462729f3560090f772567aee06d53c19f4cf78be5db289310b0b7
MD5 da09d1623d5fe527cb839dcce431b038
BLAKE2b-256 29e85587ac3aa483f3eb5de15507468186300400fd31867ff52b0a2566babda6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page