Can you be more specific on what your little game is going to parse? Is it going to parse a set of strictly defined phrases in a specific order? Or is it going to parse what the players type in (like the old sierra advanture games)? Because the second type of text is much harder to parse.

You can checkout the Parse::RecDescent module from CPAN if you decided to build it upon a set of strictly defined grammar.

And in the second case, the simplest would be to grep for recognised words in the tokenised text. And then act upon the recognised words. Otherwise you would end up with the task of writing a natual language parser with functional dependent grammar... (Good for a PhD thesis perhaps?)


In reply to Re: Parsing english by Roger
in thread Parsing english by wolis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.