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
buy buy, purchase, acquire, obtain, shop
sell sell, vend, trade, auction, market

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.1.tar.gz (11.9 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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rpgnlp-0.1.1.tar.gz
  • Upload date:
  • Size: 11.9 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.1.tar.gz
Algorithm Hash digest
SHA256 23a06bdb08839c35f32f0c10522016cab55b7373782d7ff0d9af7440b394f8db
MD5 617420c67a9815ba90d370a7cb716a39
BLAKE2b-256 c6a4566d144ce6ff9649a446d84859c801e4d80ee313280c4369ce2e1ddd5ccc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rpgnlp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bb80a972c98d71a2d47af098617216348e826d47cd7778fd4657937dc5cf80f
MD5 3d75ada9ff74aeab31dad1510433a52e
BLAKE2b-256 d0f0250b255fc7b8dfd8ac5ec82292a1b7356af6c4bd588f591e5d2e3da41f12

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