[MUD-Dev] Re: Re: [MUD-Dev] Text Parsing

Albert thecheezeman at earthlink.net
Fri May 28 20:52:06 CEST 1999


At 5/28/99 10:03:00 PM, you wrote:
>Albert wrote:
>(details snipped...)
>>
>> Then say the player enter a command like: buy the biggest ball from the
>3rd shopkeeper
>> The convoluted pseudocode would be:
>>
>> void Parse(string & rhs) {
>>         ParsedCommand pc;
>>         string word;
>> while (1) {
>> word = GetNextWord(rhs); // Would magically keep pointer position
>> if (word.empty()) break;
>> switch (GetKind(word)) {
>> case VERB:
>> if (pc.IsNewClause)
>> pc.verb = word;
>> else
>> SendToQueue(pc);
>> break;
>> case DIRECT_OBJECT:
>> if (pc.IsNewClause) {
>> pc.direct_object = word;
>> pc.IsNewClause = false;
>> } else
>> pc.direct_object += " " += word;
>> break;
>> case INDIRECT_OBJECT:
>> case ADJECTIVE:
>> // Pretty much the same code for direct_object
>> case CONJUNCTION:
>> SendToQueue(pc); // Would send a copy to the queue, but pc still exists
>> pc.IsNewClause = true; // Not technically true, but...
>> break;
>> }
>> }
>> }
>
>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.

Well, the parser could assume initially that the first verb is the direct
object. For special case commands like "sell me the ball", GetKind would
evaluate "me" as indirect. Or, since commands like those are uncommon, the
parser could go into in-depth analysis if the verb is "tell" or "order".

>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...

You mean something like "kill the ugly green troll warrior", with troll warrior
being the mob's actual name? Hmm, I suppose I see the potential for ambiguity
in GetKind, since "troll" could be interpreted either as a noun or an adjective.
I guess the brute-strength method is forcing builders to refrain from attatching
words that could be adjectives to the names of mobs. Or, perhaps make the parser
interpret by context, so that depending on the structure and wording of the command,
the parser would obtain different results. But this seems excessive to me...

>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.

Hmm, thanks for the reply. I now see some glaring errors in my thinking.
I guess it's back to the drawing board...

Author: Albert Yi (TheCheeseMan)  ICQ: 14617788
home.earthlink.net/~thecheezeman




_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev




More information about the mud-dev-archive mailing list