Passing an explicit command to the actual parser...

So, I have my Japanese parser at 80%. It can parse verbs, and look up objects. I can now create an English command from the Japanese input.

now, how do I push that back into the actual parser? The “short version” of my parser is this

Instead of answering:
         Now romaji input is topic understood;
         [Then magic happens here that turns the Japanese command into an English one]
         Let the English command be "Nakagawa, take pen".
         [inject back into the parser????]

I want to take my final text output and make that the actual players input and have the actual Inform parser take it from there. Do I just make it the player’s input, because the command I have is from the last players input

Hm. That’s awkward. You’re trying to run through the parser twice – once to figure out that this is the answering action, and then a second time after you generate your English text. That’s probably not going to work.

At this stage, you could launch an action directly:

instead try Nakagawa taking the pen;

I don’t know how you’ve got this stuff stored internally. Rather than translating to the string “take”, can you translate to the action-name called the taking action? If you’ve got an action name and an object reference, you can cobble together a stored action and launch that.

An alternative is to do all this in an “after reading a command” rule. At this point the parser hasn’t started yet, so it’s not yet the answering action; you’d have to detect the Japanese form directly. (You’d be looking in the “player’s command” snippet, rather than “the topic understood”.)

The advantage of the “after reading a command” rule is that you can rewrite the buffer however you like, and the parser will run on it. See chapter 17.31.

I’m liking the “After reading a command:” idea. It has two benefits and one downfall.

  1. It moves my parsing code closer to parsing type stuff.
  2. I can rewrite the players command

the loss is:

  1. I have the parser attached to Kaori’s “ask” so when she’s in another room, the parser doesn’t even fire, the “normal” parser lets me know that she’s not there and the ask fails.

Now you talking about putting together a stored action. I’ll look at that as it seems to keep the Japanese parser encapsulated in the “ask” Both are food for thought.

One more question and after this I’ll be tap-dancing on clouds (the parser almost converted a command)

I decided to go the “after reading a command:” route and manually checked if kaori is around, but in order to make Kaori not understand English commands, I did this…

[This Makes Kaori no longer understand English commands.]
Persuasion rule for asking Kaori to try doing something:
	say "何?[line break]"
	persuasion fails.

Now, let’s test it

now player's command is "Kaori, pen o totte"
now english output is "kaori, take pen"
change the text of the player's command to english output;

now kaori will not pick up the pen because persuasion fails

but when I do this.

now player's command is "Kaori, pen o totte"
now english output is "kaori, take pen"
Persuasion rule for asking Kaori to try doing something:
      persuasion succeeds;
change the text of the player's command to english output;	

I’m getting “There is no reply”

It looks like when persuasion is turned on, the system takes my original unparsed Japanese command and feeds that as a ask to her because it doesn’t understand “pen o totte” and does not feed it my translated input.

Ok, I have it backwards…

now player's command is "Kaori, pen o totte"
now english output is "kaori, take pen"
change the text of the player's command to english output;	
Persuasion rule for asking Kaori to try doing something:
      persuasion succeeds;

now it’s parsing the command before I can make persuasion succeed, and it’s blocked! (Persuasion fails)
What should I do here?

Do you have the persuasion rule in your code block? That’s going to give you problems (in fact, it’s a bug that that compiles at all). Each rule should be its own code block.

This means, if I’ve got it right, that somewhere else you should have:

Persuasion rule for asking Kaori to try doing something: if [some global flag you set, probably], persuasion succeeds.

and then in the place in your code block where you have “Persuasion rule for asking Kaori to try doing something,” you just put some code to set the flag. (It would be something like “Now speaking Japanese is true”, if you’ve defined “speaking Japanese” as a global with “Speaking Japanese is a truth state that varies”; and then you would use “Speaking Japanese is true” in your persuasion rule.)

Hope this helps, and apologies if I’ve misunderstood what you were doing.

Halkun, I can’t be of any help to you here, but I just wanted to say I admire your drive! This seems like a heck of a project to be undertaking, and I look forward to seeing it in action.

Thanks! I know I keep asking obnoxious questions. The parser is the really big hurdle, after that… Well wait to you see what I have in store when I start pushing Glimmr around :slight_smile: