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.1.tar.gz (194.3 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.1-cp39-abi3-win_amd64.whl (777.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

conventionalrp-1.2.1-cp39-abi3-win32.whl (706.2 kB view details)

Uploaded CPython 3.9+Windows x86

conventionalrp-1.2.1-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.1-cp39-abi3-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

conventionalrp-1.2.1-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.1-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.1-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.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (966.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

conventionalrp-1.2.1-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.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

conventionalrp-1.2.1-cp39-abi3-macosx_11_0_arm64.whl (892.7 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

conventionalrp-1.2.1-cp39-abi3-macosx_10_12_x86_64.whl (951.0 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for conventionalrp-1.2.1.tar.gz
Algorithm Hash digest
SHA256 6f3284841486b6cebc5482c206e952d8d35307239b26d084b4c8fc9b840a7fa7
MD5 4c1485df34ef8ce24aac23f30c094ea1
BLAKE2b-256 81971d589601f5c078c677a91e9c114a0231df70d7dbbe634dbc07ee24a925d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8d4b725fcb838ad36f4be0709dedf168aa95f0c142b82e7e2fe7bae37b6af7df
MD5 26f57dafad862c1d30facbbd45d9608a
BLAKE2b-256 18be3a3a1df7abd6e64d8f9e607505cce76fd3a2aeb3cd76ef12d0f067e635ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 6b963a06f8e12899f1c09517bd62267b25055e07833563b5969377045aeaf074
MD5 b95fafac6ed3de16605fb1e446523222
BLAKE2b-256 e818ac3c0dbb7d7c1455446e09791ace6ea25af19ef132761a7466679c45c4fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 87d7badbb8b65fb159ea29a3e9c76a5ffe3a892af2ef167839d842179236efcc
MD5 587bbeda869176b51d66524ac7bf236d
BLAKE2b-256 e98a1d5e46452e6c3242bd2ffa63082d6d0e0f4b3058fc18264cf7148a06b31d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e48fbbb6b491399885e35adbb218c2652a4dd59bd3d53dbfbddd73e78eca2823
MD5 4dd5b53f7d96f1dc9b6fe08b338910be
BLAKE2b-256 ded03711f4c32dbf66fe320a82c81d4c3094fede4de5e88c816d5b3a4790344d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 2152c49fe5572b313e2c8f60522e2f5f226ba797255927fe8446100359759117
MD5 351c9f5e70e837a5b2f4e2cddcc88cdf
BLAKE2b-256 2c0b42c4679891bf22140100854c0c2045758d9d190c6796ec8abdfa35ed5692

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1dc93579bdefbcc5abcf6667cc1966e65a6dee7e33bde8046eec0de2c3c1726e
MD5 0938decf25c4eccf4941718cd83d6cf3
BLAKE2b-256 b9ad291c5d99d1682ea6eae859694def25590b7a663be10c687da1c9267cc096

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4d2adab7d2c92d9d428e88442170779c37620b7748cb47a6919e5538c50afa3a
MD5 940351f7e40e17dbe45ab78ca0327bb3
BLAKE2b-256 5bd0d3b64ada27bbec93810e0dc589156f96322ed137b9f331e6801c5843ee57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 1924bcb501bd0e275428f8d72f035bcb46c27b5aab00ef48a118bf5d16ad4bdd
MD5 3e80f914b50dde725e6a311adf612f6c
BLAKE2b-256 4c6be97ec640ccc32dca589f4503ce2a66b03586e8ec099e3a33be38d42aeed2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 dc2b7d2bbea322b003b4e9e7ee3093e789d655357ec5a2ebb9c0a20e5becc441
MD5 e74fda1e9c0a40b505d17cc743e72b6f
BLAKE2b-256 e5d24f5f471185a7d7543934d4ff1a909bcc0a4c394422d81de93c6d4bcb3ba7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 14e8fb81f8bdf62026ef6543542ba0e93a63f480f59d9d7bcbe7b6313d9821eb
MD5 841c63349b3d640e79c389ddad08238e
BLAKE2b-256 67a12dd3228d237cee44286ac240e51508c13eda84631e1010879f4aca0f88d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 abe319ea96045b1f202b2f28d62820ef4c6a341585b455b1a726eeb550d1ce38
MD5 3fd42792a97471c2e320728fe4bcf63b
BLAKE2b-256 1cbfc25bdeab157612d46f1400c60cb204b3d241df858b34078b6e0aec86fea3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 9d7ad22cf2f8527c778592cc85e4a7cfe02a077b774f75a336efd751e27bd149
MD5 400c6fcf00bff9f4a3b1114d6b71a26a
BLAKE2b-256 4c960977703c4fc5c5da5fd4b6c975e55c1f75846b8c6dd4aee6b30559626378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d02044bb12b732fe080be0bfde3fcb11b16b643c4a73c5d37ce8ee1aac3c9d2
MD5 3cdcf9cd93bcb2ff9814163c362871ce
BLAKE2b-256 335d68feb6a8b75821de10e07ef7bd210402fcbe637f9bb9d9656f6af4faed93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for conventionalrp-1.2.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4b4a7d356e0171b1e89903ee1ee142d868be96524799c0982d6a57d7aff03848
MD5 6b5d3ee7c8b12cb6631a7c807c800d34
BLAKE2b-256 3fb094c448d24c13cc738a5b22616b4587839919d5b95a530a9a23b571e23621

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