Skip to main content

A natural language parser for RPG text commands. Extracts actions, subjects, directions, instruments, modifiers, and topics from player input.

Project description

rpgnlp

A natural language parser for RPG text commands. Extracts structured data — actions, subjects, directions, instruments, modifiers, and topics — from free-form player input.

Installation

pip install rpgnlp

On first use, the required spaCy language model (en_core_web_md) and NLTK data (averaged_perceptron_tagger_eng, punkt_tab) will be downloaded automatically if not already present.

Quick Start

from rpgnlp import NLPEngine

engine = NLPEngine()

result = engine.run("attack the goblin with a sword")
print(result)
# {
#     "action": "attack",
#     "subject": "goblin",
#     "direction": "",
#     "instrument": [{"name": "sword", "quantity": 1}],
#     "modifiers": [],
#     "topic": ""
# }

Output Fields

Field Type Description
action str Canonical action (e.g., "attack", "travel", "speak")
subject str Target noun phrase (e.g., "goblin", "red door")
direction str Cardinal/compound direction (e.g., "north", "south east")
instrument list[dict] Instruments with name and quantity
modifiers list[str] Adverbs or manner words (e.g., "quickly", "haste")
topic str Conversation topic after "about" (e.g., "plan")

Some Supported Actions

Action Examples
attack attack, hit, strike, slash, stab, shoot, kick
light_attack poke, prod, tap, flick, slap, nip
heavy_attack smash, crush, demolish, obliterate, shatter
travel go, run, walk, sprint, climb, swim, fly
speak talk, say, ask, whisper, shout, demand
inspect look, examine, observe, study, check
search search, hunt, investigate, scout, seek
defend block, parry, dodge, guard, protect
use use, activate, equip, drink, eat, open
take take, grab, loot, steal, collect
drop drop, place, put, discard, give
cast cast, conjure, summon, enchant, heal
sneak sneak, hide, lurk, prowl, shadow
rest rest, sleep, camp, meditate, wait
trade buy, sell, barter, haggle, shop

Examples

engine = NLPEngine()

# Movement with direction
engine.run("run north east")
# action: "travel", direction: "north east"

# Speech with topic
engine.run("tell the guard about the plan")
# action: "speak", subject: "guard", topic: "plan"

# Multiple instruments with quantities
engine.run("attack the goblin with two daggers and a shield")
# action: "attack", subject: "goblin",
# instrument: [{"name": "daggers", "quantity": 2}, {"name": "shield", "quantity": 1}]

# Modifiers
engine.run("run south with haste")
# action: "travel", direction: "south", modifiers: ["haste"]

# Compound actions (split by "and" or "then")
results = engine.run("go north then attack the troll")
# Returns the last action; compound actions are processed sequentially

Requirements

  • Python >= 3.9
  • spaCy with en_core_web_md model
  • NLTK

License

MIT

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

rpgnlp-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

rpgnlp-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file rpgnlp-0.1.0.tar.gz.

File metadata

  • Download URL: rpgnlp-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for rpgnlp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 97d56fba950d87b34af56c689d5023b1135722f3a401b6c2a147efd905986884
MD5 11c199b5f828c9fcf00b914945295bb7
BLAKE2b-256 cbaa37ff20b1d545adc273e0cb9d5a51f03c8720456801199ed822305b06cea2

See more details on using hashes here.

File details

Details for the file rpgnlp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rpgnlp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for rpgnlp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2546adaa91ec2e2c50ff0b1872fb8c33ae6bba7fc76a959e74f2b4b87d13e514
MD5 bf6cf1cc83240e7552043c0d06539d47
BLAKE2b-256 dc72ee4a4aa963a26049748d4aebcc6d4052a6af5494c1daecae41cc9069814f

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