I’ve had great success with the “Misunderstood Word” extension. I love it when the game says
“I didn’t understand the word ‘foo.’”
It tells players they don’t need to bother with that phrasing anymore. But unfortunately, it can’t handle commands like
“GET TO DOOR”
If the preposition isn’t used in a matching grammar line, Inform recognizes the word, but can’t match it to an object, so we’re stuck with “You can’t see any such thing” even when there is clearly a door right there.
Does anybody have suggestions for writing a “Misunderstood Noun Phrase” extension that will complement “Misunderstood Word?” How would it work? What information could it give the player?
I just got an idea for how this would work, but it’s extremely low-level and I’m not even sure it can be done in I6:
Search Inform’s dictionary for all words. If a word is used in an object (or value)'s parse-name routine, mark it as a noun-word. If it’s used as a “command,” mark it as a verb-word. All other words are marked as prepositions.
If a command contains a preposition where the parser is looking for a noun, a new parser error is generated: “preposition cannot be used in that context.”
Given the complexity of noun parsing, I’m not sure this is possible at all, but I’d like to hear what you think. Maybe it would just require a little input from the author to work?
As I said in a different thread – given the simplicity of the standard IF grammar, it is much easier to simply hard-code a list of prepositions and then provide a hook for the author to customize this list. (I believe it’s “in”, “on”, “into”, “onto”, “to”, “at”, “with”. There are other fixed words in the standard grammar but I’d want to think about how they behave in this context.)
Stepping back: I think it is better for a command to go wrong with “I only understood the ‘get’ part of that command”, rather than complaining about specific words. It is not fundamentally informative to distinguish between words the player has not encountered yet and words the player will never encounter.
This is what I’d want for the “GET TO DOOR” case – something like “I understood ‘get’ as trying to take something, but I couldn’t make sense of ‘to door’ as something to take in this case.”
Well, as a player I’m not sure about that – if I’ve just left the room with the statue with the nose that might be a disguised button, it does tell me something if “PUSH NOSE” gets the response “You don’t need to refer to a ‘nose’ in this story” rather than “You can’t see the nose right now.”
I guess “That’s not here, or not important” handles both those cases equally, but I always find it a little immersion-breaking; it seems to highlight the limits of how much your input is understood. Though living with those limits might be better than
going through the effort it seems to take to distinguish the cases.
By the way, the extension is listed on the I7 extensions page as “Unknown Word Error” rather that “Misunderstood Word,” in case anyone else spent a lot of time scratching their head while trying to find it.
There’s a pretty intractable problem here. To behave as wanted the parser has to be able to distinguish prepositions in a name both from prepositions in a grammar line and from other ‘non-grammatical’ occurrences of prepositions. I.e., it will have to treat the “to” quite differently in these three cases respectively: “get door to freedom”, “give door to ogre”, and “get to door”.
In effect, we want the parser to distinguish possible but unrealized grammar lines like ‘get to [something]’ from the use of names including a presposition in similarly reading commands like 'get '.
The big problem, I guess, is that the parser would have to make a distinction within what to it would seem as a single grammatical construction. Within a grammar line such as ‘get NOUN’, it would have to distinguish between the cases when an English pronoun is properly a part of the NOUN token (as in ‘get key to green door’ and when it is not (as in ‘get to green door’).
In English (to the player) the latter ‘to’ is rather part of the verb phrase (‘get to’); but the parser doesn’t recognize any such verb phrase – so it can’t but interpret the ‘to’ as belonging to the name of a potential noun. What the parser need, then, is a way to detect or abstract from prepositions that spuriously belong to the name of the noun.
I can think of two unsatisfactory ways to do that.
Make the parser disregard all prepositions while parsing a noun token. But then it would not be able to distinguish between a ‘letter to Santa Claus’ and a ‘letter from Santa Claus’; and it would interpret ‘get to green door’ as ‘get green door’.
Make the parser object with a ‘didn’t understand that verb’ or or ‘only understood you as far as’ error to any noun token beginning with a preposition. But that would preclude names like ‘Inside the Dark Cave’ or ‘off duty policeman’.
A more satisfactory way might be this.
3) Make the parser object with a ‘didn’t understand that verb’ or or ‘only understood you as far as’ error to any noun token beginning with a preposition unless it actually matches an object. If that can be done, it would reject ‘get to door’, unless there is an in-game object called e.g. ‘door to freedom’ (in which case it would interpret the command as ‘get door-to-freedom’).
Just to clarify, I’m not asking for the parser to be smarter about picking a real noun out of the command, I just want a better error message than “you can’t see any such thing” when it’s not even clear what phrase it was trying to match to a object. I’d be fine with Matt’s version here (“I couldn’t make sense of ‘to door’…”).
So maybe general knowledge of prepositions isn’t necessary just to write an extension that provides snippets for things like the person asked, verb, noun and second noun, as the parser interpreted them.