1999Q2/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev] Text Parsing -->
<!--X-From-R13: "Ylybgna" <xlybgnaNxlybgna.sbepr9.pb.hx> -->
<!--X-Date: Fri, 28 May 1999 14:08:53 &#45;0700 -->
<!--X-Message-Id: 000901bea94d$c9dc8180$0100a8c0@hell -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 199905281836.LAA11685#penguin,prod.itd.earthlink.net -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev] Text Parsing</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:kylotan#kylotan,force9.co.uk">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00339.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00341.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00336.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00342.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00340">Author</A>
&nbsp;|&nbsp;<A HREF="#00340">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00340">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev] Text Parsing</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: &lt;<A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A>&gt;</LI>
<LI><em>Subject</em>: Re: [MUD-Dev] Text Parsing</LI>
<LI><em>From</em>: "Kylotan" &lt;<A HREF="mailto:kylotan#kylotan,force9.co.uk">kylotan#kylotan,force9.co.uk</A>&gt;</LI>
<LI><em>Date</em>: Fri, 28 May 1999 22:03:22 +0100</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Sender</em>: <A HREF="mailto:mud-dev-admin#kanga,nu">mud-dev-admin#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
Albert wrote:
(details snipped...)
&gt;
&gt; Then say the player enter a command like: buy the biggest ball from the
3rd shopkeeper
&gt; The convoluted pseudocode would be:
&gt;
&gt; void Parse(string &amp; rhs) {
&gt;         ParsedCommand pc;
&gt;         string word;
&gt; while (1) {
&gt; word = GetNextWord(rhs); // Would magically keep pointer position
&gt; if (word.empty()) break;
&gt; switch (GetKind(word)) {
&gt; case VERB:
&gt; if (pc.IsNewClause)
&gt; pc.verb = word;
&gt; else
&gt; SendToQueue(pc);
&gt; break;
&gt; case DIRECT_OBJECT:
&gt; if (pc.IsNewClause) {
&gt; pc.direct_object = word;
&gt; pc.IsNewClause = false;
&gt; } else
&gt; pc.direct_object += " " += word;
&gt; break;
&gt; case INDIRECT_OBJECT:
&gt; case ADJECTIVE:
&gt; // Pretty much the same code for direct_object
&gt; case CONJUNCTION:
&gt; SendToQueue(pc); // Would send a copy to the queue, but pc still exists
&gt; pc.IsNewClause = true; // Not technically true, but...
&gt; break;
&gt; }
&gt; }
&gt; }

How can you tell, out of context, whether a noun is the direct object or the
indirect object? (eg. in "get the bag" and "put the ball in the bag" the
word "bag" is direct in the first instance, and indirect in the second.) I
would think you'd need to be looking for other clues, such as
prepositions/prepositional phrases to indicate that you are now expecting an
indirect object.

If you make it so that all noun phrases contain X adjectives and 1 noun,
that is easy - If this is a noun, and if we have no direct object, this word
is (probably) the direct object. If we have a direct object already, this is
the indirect object instead. However, it looks like you were allowing for
multiple-word nouns...

A simple (but by no means totally sufficient) way to represent this would
obviously be a variable to say whether you are expecting direct or indirect
next, initialised to direct. This could change when you come across a
preposition/prepositional phrase. If you want prepositions to be optional
(so that "get axe bag" works), it would also have to be changed when the
noun you read in doesn't resolve to the same object as the noun you have
already.

Also, bear in mind the order of the two objects is not always fixed
(contrast "give the guard 10 coins" with "give 10 coins to the guard").
However, given that you know the verb/command, it is probably trivial to be
able to swap your objects when necessary.

(By the way, feel free to correct any misuse of linguistic terms - it's been
a while.)

Kylotan.



_______________________________________________
MUD-Dev maillist  -  MUD-Dev#kanga,nu
<A  HREF="http://www.kanga.nu/lists/listinfo/mud-dev">http://www.kanga.nu/lists/listinfo/mud-dev</A>


</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00336" HREF="msg00336.html">[MUD-Dev] Text Parsing</A></STRONG>
<UL><LI><EM>From:</EM> Albert &lt;thecheezeman#earthlink,net&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00339.html">Re: [MUD-Dev] Multi-threaded mud server.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00341.html">Re: [MUD-Dev] [TECHNICAL]  How to generate pre-processor output (template problem).</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00336.html">[MUD-Dev] Text Parsing</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00342.html">Re: [MUD-Dev] Text Parsing</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00340"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00340"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Re: Re: [MUD-Dev] Text Parsing</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00360" HREF="msg00360.html">[MUD-Dev] Re: Re: [MUD-Dev] Text Parsing</A></strong>, 
Albert <a href="mailto:thecheezeman#earthlink,net">thecheezeman#earthlink,net</a>, Mon 31 May 1999, 21:37 GMT
<UL>
<LI><strong><A NAME="00367" HREF="msg00367.html">Re: [MUD-Dev] Re: Re: [MUD-Dev] Text Parsing</A></strong>, 
Travis Casey <a href="mailto:efindel#io,com">efindel#io,com</a>, Tue 01 Jun 1999, 02:21 GMT
</LI>
<LI><strong><A NAME="00370" HREF="msg00370.html">Re: [MUD-Dev] Re: Re: [MUD-Dev] Text Parsing</A></strong>, 
Mik Clarke <a href="mailto:mikclrk#ibm,net">mikclrk#ibm,net</a>, Tue 01 Jun 1999, 05:48 GMT
</LI>
</UL>
</LI>
</ul>
</LI>
<LI><strong><A NAME="00336" HREF="msg00336.html">[MUD-Dev] Text Parsing</A></strong>, 
Albert <a href="mailto:thecheezeman#earthlink,net">thecheezeman#earthlink,net</a>, Fri 28 May 1999, 18:51 GMT
<UL>
<LI><strong><A NAME="00340" HREF="msg00340.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Kylotan <a href="mailto:kylotan#kylotan,force9.co.uk">kylotan#kylotan,force9.co.uk</a>, Fri 28 May 1999, 21:08 GMT
</LI>
<LI><strong><A NAME="00342" HREF="msg00342.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Greg Miller <a href="mailto:gmiller#classic-games,com">gmiller#classic-games,com</a>, Sat 29 May 1999, 00:51 GMT
</LI>
<LI><strong><A NAME="00348" HREF="msg00348.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Mik Clarke <a href="mailto:mikclrk#ibm,net">mikclrk#ibm,net</a>, Sat 29 May 1999, 21:14 GMT
</LI>
<LI><strong><A NAME="00357" HREF="msg00357.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Travis Casey <a href="mailto:efindel#io,com">efindel#io,com</a>, Mon 31 May 1999, 03:34 GMT
</LI>
</UL>
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00343" HREF="msg00343.html">Re: [MUD-Dev] Text Parsing</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sat 29 May 1999, 01:10 GMT
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>