Are there any existing interactive fiction text parsing engines that I can embed in another game or application?

I'm looking to use something as a library. I can pass it the available objects and verbs from my own side. It will parse the sentences from the user and give me back some sort of structure/AST describing what the user asked for. Then my own code can then act upon that request.

I don't need something SIRI level. The simple sentences and actions that current IF games support is fine. But I'm not looking to write a whole text/sentence parser myself.

This isn't an If game and I can't write it entirely in an interactive-fiction language like inform 7. Unfortunatly, I can't seem to find any examples of anyone using the text parsing capabilities of these engines without writing the entire game in that engine's language.

  • \$\begingroup\$ Interesting idea. I don't think embedding a z-machine would be an impossible task (which means you could use inform to write the if-part) - afair, windows port of some z-machine had the z-machine run in a separate thread from the UI, so it kinda already does (parts) of what you want. \$\endgroup\$ – Jari Komppa Oct 5 '12 at 8:20
  • \$\begingroup\$ All that said, it's entirely possible that what you actually want to do is easier to do without embedding a whole IF virtual machine.. \$\endgroup\$ – Jari Komppa Oct 5 '12 at 8:21
  • \$\begingroup\$ yeah, it looks like I'll have to write my own parser. \$\endgroup\$ – DragonFax Oct 5 '12 at 10:40

This is a tricky question. It's possible to extract the text parsing functionality from one of a number of IF engines written in general-purpose programming languages (i.e. not something like Inform). Some possibilities might be Pyf, and the Aunt and Butler's engine. If you expand your search to muds you'll have an order of magnitude more choices (here are lists of open source muds and Python muds specifically).

However the tricky part, and from your question you understand this, is resolving the parse in the context of the game world. This is the hard part, and something like OpenNLP won't get you there unfortunately. The problem is that these IF engines and muds each have their own way of doing that and it may be difficult to reconcile with how you're designed your world model.

Luckily there are many resources to writing an effective parser and resolver. I'm just going to throw some links at you,





















  • \$\begingroup\$ Yeah, I've written parsers for programming languages. Enough to know tackling natural languages is a different beast. \$\endgroup\$ – DragonFax Oct 5 '12 at 18:53
  • 2
    \$\begingroup\$ Remember, it's not just the natural language parse, it's the world model analyzer that'll take all your time :). \$\endgroup\$ – georgek Oct 5 '12 at 20:27

Would this be useful to your project? I believe what you are asking for is NLP and IF is just a specific use case.


Well, if you wish to check that the correct combination of a noun and a verb was found in the sentence and not so much about structure, grammar and other aspects:

I suggest downloading this http://wordnet.princeton.edu/wordnet/

You could use it to basically check if a synonym exists for both the verb and the noun you are looking for in a sentence without having to manually type in all the viable synonyms for each word.

If you wish to see text adventure game source code that was recently released, you could find some games here (just hit Ctrl + F) and type text


There is also a list of Text Adventure game engines here:


If you require something more, please elaborate.

  • \$\begingroup\$ Proper NLP seemed over-kill, and also seemed to focus on Data Sciencey type stuff. Where you want identify if a sentences in a large dump are happy or sad, or mentions people vs things. Where-as I wanted to parse one sentence perfectly, and arrive at "the user is saying do VERB to NOUN". Even if it only parses a few different forms. \$\endgroup\$ – DragonFax Oct 5 '12 at 18:56
  • \$\begingroup\$ I added some links to text adventure game engines. \$\endgroup\$ – AturSams Oct 5 '12 at 19:21
  • \$\begingroup\$ Thanks, I've been reading the NLTK (python) book, which is a good tutorial on the basics of NLP usage. But parsing a single sentence into a "meaning" is still a non-trivial thing. \$\endgroup\$ – DragonFax Oct 7 '12 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.