[Tutor] Textparsing, a better way?
Zak Arntson
zak@harlekin-maus.com
Tue May 6 15:30:03 2003
> Two text adventrue/interactive fiction systems written in Python (there
> may be more):
>
> Python Universe Builder
> http://py-universe.sourceforge.net/
> It claims that its parser is better than Infocom's in some ways*.
>
> PAWS (Python Adventure Writing System)
> http://w3.one.net/~wolf/PAWS.shtml
<SNIP>
> --
> Norvell Spearman
Thanks for the links! Looking through them, it's interesting to see their
approach to textparsing. They both go through steps, from finding the verb
in the sentence, to finding the preposition, etc.
I drew up a state machine, going from one word to the next. I'm not wise
enough to know all the advantages and disadvantages compared to the PAWS &
PUB methods, save that my method is easier for me to draw on paper :)
I'm also loving Python's inherent coolness. My sentence enters the parser
like "get the big blue rock and the shiny beetle with the tongs" and comes
out a dictionary, like:
{ 'verb': ['get'],
'dobj': [ {'obj':'rock', 'adj':['big','blue']},
{'obj':'beetle', 'adj':['shiny']} ]
'iprep': ['with'],
'iobj': [ {'obj':'tongs'} ] }
If anyone's interested, I'll try and draw up my current state machine.
It's not perfect (can't parse all English sentences, nor all the possible
text adventure commands, yet), but it's not bad.
--
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em