Clarifying the parser's choice: one noun and one topic

I’ve read the posts about how the Clarifying The Parser’s Choice activity only runs when the command has a single noun. In the MWE below, I’ve got a command that takes one noun and one topic, and an unexpected parser clarification.

"Tester"

House is a room. The toy dog is in the House. Spot is an animal in the House. Understand "dog" as Spot.

Rule for clarifying the parser's choice of Spot: say "(good old Spot)[command clarification break]".

Petting is an action applying to one thing. Understand "pet [someone]" as petting. Report petting: say "You pet [the noun]."

Commanding it to is an action applying to one thing and one topic.

[Line A] Understand "command [someone] to [text]" or "command [someone] [text]" as commanding it to.

[[Line B] Understand "command [someone] to/-- [text]" as commanding it to.]

Instead of commanding Spot to "sit": say "Spot's never been very good at the obedience thing."

Test me with "pet Spot / pet dog / take toy dog / give dog to Spot / give dog to dog / command Spot to sit / command dog to sit / command spot sit / command dog sit".

The unexpected bit is that “test me” command [7] produces a parser clarification that includes an unrelated word from the command: “(Spot to)”. Test command [9] produces the clarification “(Spot)”, without the extra word but also not using the explicit rule given for CTPC. The latter might just be a case of CTPC only happening when the command includes a single noun, but the former seems different?

Interestingly, if I swap out Understand Line A for Understand Line B, both test commands [7] and [9] give the same response: “(Spot)”.

For my purposes, the Line B solution is probably fine. Still, I thought the unusual behavior of Line A was worth mentioning here. I’m curious to know what’s going on.

This is a messy area of the parser and I can’t give you a complete explanation.

“(Spot to)” isn’t an extraneous word; it’s missing words, I think. The clarification routine tries to print the entire matched command starting from the inference point. Thus “(the toy dog to Spot)”. When you have grammar line A, it’s matching the grammar line “command [someone] to [text]” so it should print “(Spot to sit)”. But the topic doesn’t make it in there. I think this is because the internal parsing structure just doesn’t contain topic words; the topic is kind of a hack and the parser can’t spit it back out at that point.

Possibly it should be printing “(Spot to that)” as a fallback.

When you enter COMMAND DOG SIT, it’s matching the grammar line “command [someone] [text]”, so it should print “(Spot sit)” or “(Spot that)”. Again, the topic gets lost. But this is still not a simple one-noun clarification, so the CTPC activity does not run.

When you put in understand line B, there winds up being a single grammar line “command [someone] [OPTIONAL-TO] [text]”. Here the clarification routine skips the optional token entirely, and I don’t know why. (I’d expect it to spit back whatever words matched the token.)