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.2.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.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rpgnlp-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 fa0fc78356bc6e3f9c2aa33456ef1abd6b7be30cc5cdf9e74aa52468c142ac9f
MD5 ded65546ab350c0bdb7d6f65f613d6df
BLAKE2b-256 d0257fe0df1d31923e224f3cf14f145cc6418293cd0731c979ee41edf9529aaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rpgnlp-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63890ea295fa5d526127ed0edf48e38e5392f7d27b5265e84e9b39a1ac99ff62
MD5 dffc8695efc162b15d2dc65b8b39dd42
BLAKE2b-256 a85dd0204ae6ee3c1f842d86baa498ca9f8f9a63e044ec247293ae1766c21e0e

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