Request (unless it's already possible) - getting the noun from parsed command

Started by Rui 'Trovatore' Pires, Mon 08/11/2004 15:33:13

Previous topic - Next topic

Rui 'Trovatore' Pires

Ok, if this is already possible, please tell me how it's done, but if not, treat this as a request (not top-priority, but it *should* be added anyway - so AGS can be even more flexible. Currently, the text parser lacks a bit, and it needs this sort of face-lift).

Suppose the player types in "get rock". I want to be able to acess the word "rock", or whatever the NOUN is, so I can, using an array of strings that is set everytime a player enters a room, check out whether the noun IS in the room, so to speak, (thanks, Dave Gilbert, for the quick course in arrays and for the whole string array idea!) so I can decide whether to give an "Object not found" error or a "that isn't possible" error - and in any case, I'd like to be able to say, "Smell the %s? What on earth for?".

Is this currently possible? Again, what I need is simply a way to get the NOUN of a command/string (not necessarily the second word - examples being "pick up rock" or "smell exhaust tube").
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

stuh505

I have been doing some work on trying to write text parsers for natural language, and the question you propose is not nearly as easy as you might think.  The English language is extremely complex.  To detect the noun would require either a database of noun's which it could choose from, or it would require a database of other words telling their word type which it could use to determine a noun by it's grammatical placement.  I don't think this is going to happen in AGS, nor do I think that it should happen.  I think you should just write a function to find the noun, by checking a list of noun words which you define.

Rui 'Trovatore' Pires

Why not? Why not check the word group, or something, and subdivide words into VERBS and NOUNS? It already groups words by synonims, why not into these 2 sub-categories?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Pumaman

Well, in order to do this you'd need to be able to set all words in the dictionary as Nouns or Verbs.

What happens if there are two nouns in the player's input?

I understand where you're coming from, but I'm just not really convinced this important enough to make an integrated feature.

Rui 'Trovatore' Pires

1 - AGS is very powerful and flexible, but while text parsing is possible, it's still a pain in the buttocks. That little bit of extra work - which might well be optional, only for those who really want to go the whole way - wouldn't really be a setback. I mean, the programmer already has to almost import an entire dictionary, it wouldn't be that much of a chore.

2 - An IF parser would be expected to understand such complex sentences with many verbs and nouns. No graphical parser (AGI and related) is expected to do more than verb/noun. And if said noun has more than one word, that wouldn't be a problem, after the "two-word words" thingy in my other thread. ;)

3 - As I said, AGS's text parser needs a facelift, like AGS's dialog system, as you yourself have said awhile ago. In my view, if text parser isn't developed alongside the rest of AGS - despite the obvious fact that almost no one uses it - it might as well be scratched off, don't you agree? Which I wouldn't like, and I'm sure you wouldn't either, but the fact is, while the entire AGS is already at version 2.62, the text parser is really many versions behind. What I'm suggesting is a single way to workaround a much bigger problem, too.

Have I been convincing? ::)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

stuh505

Convincing?  No...

Basically, it sounds like you want to write a function...but you don't know how...so you're asking Pumaman to write it for you.

What you are proposing is entirely possible to do in AGS.

On a simple level, it would be easy to implement somethign that worked pretty well in your game.

To do it actually right, so that it could actually detect the noun phrase in a sentence, would be groundbreaking research in the field of AI.

But either way, you're not askign for core functionality...all of this can be done already....so just write the function yourself if you want it so badly!

Rui 'Trovatore' Pires

Ok, then let's get back to the 1st post - i.e., if it is possible, how? The player types in "get rock". How do you extract "rock" from that string? I just kept assuming it wasn't possible, and I still don't see how it's possible, but if, by all means, you can help, please do. How to extract the "rock"?

EDIT - I'd just like to point out that there is no lazyness in this matter - I really HAVE thought hard about it, and asked around to fellow AGSers, none of whom could help me. I've scripted damn interesting functions already (at least I like to think of them as interesting). I kinda feel that you believe I'm being lazy. It's not that at all.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

stuh505

First of all, I don't think that you need this function.

The only possible reason you would want it, is so that you can say "what do you mean by rock?" for a word that wasn't defined.

If they are going to try to do something with anything in your game that they CAN interact with, than you should just define that explicity.  Ex:

<pick up | take | get> <rock>

However, if you REALLY want the game to know what the noun in your sentence is, there are many approaches you could take.

1) Define a list of noun's, and return the first word in their sentence that matches one of the nouns from that list

Fairly crude, and cannot detect nouns which the user makes up.

2) Define a set number of sentence structures by classifying words into their part of speach.  Then make arrays to store most of the words.  Then you can analyze and determine the part of speach of undefined words based on it's location in the identified sentence structure.  You could store the sentence structure types in a node tree and then traverse this tree with the input sentence in order to determine the proper sentence type.  I can explain to you the specifics for locating the subject (noun or noun phrase) of simple sentences when I get home...I have it written down in some EBNF grammar files.

Rui 'Trovatore' Pires

1 -
QuoteThe only possible reason you would want it, is so that you can say "what do you mean by rock?" for a word that wasn't defined.

From my first post -
QuoteI want to be able to acess the word "rock", or whatever the NOUN is, so I can, using an array of strings that is set everytime a player enters a room, check out whether the noun IS in the room.
, which is basic stuff on IF, AGI and SCI but not in AGS, where the words are just abstract, not connected to any object.

2 - But that list would be needlessly and impractically huge, due to the sheer amount of synonyms - something that the parser automatically checks for anyway. Besides, things such as "light" or "water", both verbs and nouns, would cause confusion. I don't see that sort of confusion happening with my suggested distinction between nouns and verbs, not if it were carefully taken care of.

3 -Ã,  Your explanation lost me completely, I'm afraid.

EDIT - And as concerns "need", there's lots of things in AGS that we have no "need" of, such as the mouseover GUI object pic and the SaveCursorForLocationChange, and SkipCharacterMovement (or whatever it is that teleports the character to the final destination). But these are the things that make AGS flexible and powerful. I'm only suggesting a similar thing to a much underrated feature of AGS.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

rich

Hmm... I agree with your request that two-word words (like "pick up" for "get") should be acceptable synonyms. That's how it is with AGI and that's the way I like it. I wouldn't want to see AGS lose its text parser either... that's one of the big reasons I plan on using AGS for my next project. I won't if it loses its text parser.

As for this request... I'm not sure how necessary it is... I find with anygame, it is the programmers responsibility to manually put in responses in every room for every possible thing that someone could enter. If the user types "look","rock" have a response built in that checks that and says "the rocks are useless to you" or whatever. Or put it in the global coding so whenever someone types "look","rock" in any room it will give some response. Whenever I felt close to releasing a game, I would have friends play the game and anything they typed in that had no response, I would add a response for. It's tedious work, but I feel it makes a game much more interesting than having auto-responses that just pull out nouns.
I'm so excited!

Pumaman

QuoteHave I been convincing?

Let me re-phrase... I can see how this feature would be useful, but there are hundreds of other outstanding suggestions for AGS that would also be useful. What I'm really asking is directed at everyone else on the forums -- would anyone else find this feature useful?

In an ideal world everything that everyone suggests would be implemented, but sadly there aren't infinite hours in a day.

  :)

Rui 'Trovatore' Pires

Gotcha, CJ. I'll just sit quietly, then, and threaten everyone with my pointy stick to voluntarily and of their own free will agree I'm right (OR ELSE!). ::)

Rich - I still get the impression people don't know where I want to get at. As it is, if you want to script "get rock" in a room with a rock, or where a rock WAS, that's all right. But if you try if on a room with NO rock, you'll get an error message that COULD (and in an AGI or IF engine WOULD) be much more precise and customised. Manually doing that for all rooms would be a pain. And in order to do it, I'd need to know what object the player was interacting with. The alternative Stuh suggested is good but very impractical, due to AGS's non-parsing commands not handling synonims - the list would be too nig and complicated, and the presence of verbs like "light" and "water" would be a killer.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

rich

Okay, it doesn't have to put manually in every room... you could put in the global script parser... if(said("get rock")) then display("Rock? Are you crazy?");

You would have to manually insert a response for each noun into the global text, but I think that's alright. Then in rooms where there are rocks, have a custom response for those rooms to override the global script parser. That worked in AGI. I assume it works in AGS... I hope it does!
I'm so excited!

Rui 'Trovatore' Pires

Kay, I stopped to really think about it, considering all the information exchanged. Let me see now...

To be put in a function that would be called at the very beginning of every CallRoomScript event in rooms -

1 - Use StrContains to check for the existence of noun "buffer", for example. And if it doesn't contain the noun, move on to the next noun in the list. This could be done with an array string and a "while" loop, correct? Please answer me, I'm not sure.

2 - When we have a match, match it against another string array, one that contains the strings that make up the contents of the room.

3 - If there isn't a match, run a function that would give a standard "That isn't here" response (although a "The %s isn't here!" would still be better, and not impossible, I guess), else run the rest of the script.

Step one is stuh's suggestion, and it still sounds huge and momentous, especially since all the nouns AND synonims would have to be entered here even though they had already been entered in the word list - it's a second helping of an already huge work - , and it still sounds better (and more fool-proof, too) to have that ability to compare it to the actual wordlist instead, but if CJ really doesn't see this coming (and it seems no one else does, either) this might be the best solution, yes. You - yes, YOU, the reader - what do you think of all this mumbo-jumbo? Does it sound like it might work?

The problem remains, though, that confusion WILL arise when using verbs like "light" and "water"... <sigh> but without the feature I asked for, I think that one really can't be worked around.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

stuh505

why not just make a function that gets called whenver the room did not have a specific response to the phrase.

the function would first check through the words and let you know if any invalid words were used.  if all the words were valid, just say:

You can't pick up rock

or whatever they said

If you don't want to simply spit back what they wrote, you could make a function to determine what the verb they used was...and then write a generic error for each verb:

ex: You can't take that.

Rui 'Trovatore' Pires

That's not very informative... "You can't take that" can refer to a very big spaceship, and it's usually seen as a message to show when the object IS in the room. If someone playing AGI or IF saw THAT message, they would assume the object IS in the room, they just haven't spotted it. That is no help at all.

And besides, finding out what verb they used would be the same problem - HUGE list for verbs, and still there'd be the problem with "light" and "water".

QuoteThis could be done with an array string and a "while" loop, correct? Please answer me, I'm not sure.
Quotewhat do you think of all this mumbo-jumbo? Does it sound like it might work?
DO you think it might work, stuh? You sound like you know your stuff, I'd like your opinion. ANd barring any other surprise, I think that's the method I'll have to use.

And to all you people saying "why don't you just test it?": I will. I'd just like to know if my logic sounds stable. It's the first time I'm dealing with arrays, and also the first time I write a template, and I'd like everything to be rock solid. I figure, if everyone thinks the logic is solid then it probably is, and I can get to work on the huge amount of work it'll take me.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

stuh505

Well, you would have to define a list of what nouns were in each room...which would be an extreme pain in the butt, especially because players often think they see something which is supposed to be something else..and considering the number of synonyms.

It would be about the same amount of work to make this list as it would be to make the list of the possible verbs that the game uses...and if you made that list once, then you would have your "GetNoun" function.

Besides being a lot more work, I don't think that method would be any more informative to the player...and I don't think that's how the sierra games worked

Rui 'Trovatore' Pires

QuoteWell, you would have to define a list of what nouns were in each room...which would be an extreme pain in the butt, especially because players often think they see something which is supposed to be something else..and considering the number of synonyms.
Hence my request... so AGS could deal with the synonims itself.

QuoteI don't think that method would be any more informative to the player...
Here's a misquote from someone I asked: " If I typed in "get hose" and got a standard response, I'd assume there was a hose where I couldn't see."

Quoteand I don't think that's how the sierra games worked
Now that you've actually said that... I'm not sure either. Maybe it's not. In which case all these posts are therefore rendered quite meaningless... sorry to have wasted your time, stuh, CJ and rich. <groan> Another thread that should have been better thought of before writing.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

stuh505

Regardless of how Sierra did it, you can do it this way if you want...and you don't have to define the list of objects in each room in order to determine if the object is in that room or not.  All you need to do is define the list of verbs...take/get/talk/use...I don't know what's in your game, but this list is probably not going to be very long so it shouldn't be too hard to do.

Let's say you have a room with a rock and a broom in it.  You can take the rock or the broom, and you cna use the broom.

I forgot how the room scripting details work, but I can tell you generally how to do it.  In the room script, check to see if they are using the word "get" or a synonym of it.  Then check to see if they used the word "broom" or "rock".  If they did, give them the broom or rock.  If they didn't, then we know they tried to get something that wasn't in the room...and you can assume that whatever they tried to get was the part that they said AFTER get.  If they didn't use "get" at all, then we can just throw a generic "i dont knowwhat you mean" type of thing.  You can have now a customized response for each type of verb that will be able to respond to the noun.

So for example, if they said:

Take the bow and arrow

The generated error could be, "I would take the bow and arrow if there was one, but there isn't!"

SMF spam blocked by CleanTalk