Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Jari Komppa Oct 5 '12 at 8:20
    
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.. –  Jari Komppa Oct 5 '12 at 8:21
    
yeah, it looks like I'll have to write my own parser. –  DragonFax Oct 5 '12 at 10:40
add comment

2 Answers 2

up vote 4 down vote accepted

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,

http://www.mudbytes.net/topic-1838

http://www.mudbytes.net/topic-2962

http://www.mudbytes.net/topic-2038

http://www.mud.co.uk/richard/commpars.htm

http://groups.google.com/group/rec.arts.int-fiction/msg/f545963efb72ec7b?dmode=source

http://www.intfiction.org/forum/viewtopic.php?f=38&t=4205#p30260

http://www.tads.org/t3doc/doc/libref/source/parser.t.html

http://www.tads.org/t2doc/doc/prsseq.htm

http://www.dnd.utwente.nl/~krimud/Docs/NMAdmin/Parser/

https://groups.google.com/forum/?fromgroups#!searchin/rec.arts.int-fiction/writing$20a$20parser/rec.arts.int-fiction/VpsWZdWRnlA/2mf5y25xk7MJ

https://groups.google.com/forum/?fromgroups#!searchin/rec.arts.int-fiction/writing$20a$20parser/rec.arts.int-fiction/EfxdLAc5Tmo/Fn5CEQvZCGsJ

http://ifwiki.org/index.php/Past_raif_topics:_Development:_part_2#Parsing

https://groups.google.com/forum/?fromgroups#!topic/rec.arts.int-fiction/HJPrqQ8l9u0

http://www.kotancode.com/2012/02/15/scalamud-scala-java-nlp/

https://groups.google.com/forum/?fromgroups#!topic/rec.arts.int-fiction/to4Ut4r_qCs

http://effbot.org/zone/simple-top-down-parsing.htm

http://www.skotos.net/articles/dawnof09.shtml

http://www.skotos.net/articles/dawnof22.shtml

http://discworld.starturtle.net/lpc/playing/documentation.c?path=/concepts/parser

http://disinterest.org/resource/MUD-Dev/1999q2/010160.html

share|improve this answer
    
Yeah, I've written parsers for programming languages. Enough to know tackling natural languages is a different beast. –  DragonFax Oct 5 '12 at 18:53
    
Thanks for confirming my suspicions. –  DragonFax Oct 5 '12 at 18:53
2  
Remember, it's not just the natural language parse, it's the world model analyzer that'll take all your time :). –  georgek Oct 5 '12 at 20:27
add comment

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

http://opennlp.apache.org/

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

http://en.wikipedia.org/wiki/List_of_open-source_video_games

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

http://en.wikipedia.org/wiki/Category:Text_adventure_game_engines

If you require something more, please elaborate.

share|improve this answer
    
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. –  DragonFax Oct 5 '12 at 18:56
    
I added some links to text adventure game engines. –  Zehelvion Oct 5 '12 at 19:21
    
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. –  DragonFax Oct 7 '12 at 3:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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