How do I catch "the (something)" in a conversation topic?

Hi there. Me again. Sorry.
So, this time I’m beating my head against the wall of trying to get the parser to deal with putting “the” before a conversation topic. (and while I’m asking, how about recognizing plurals without explicitly adding them to the topic options?)
Specific example. One entry in the topic column is:

"ducks/ducklings/duck/duckling/birds/bird"					"They're so cute, aren't they? I better to get them to the river for a swim."

This table is for asking the character about something.
When I “ask Clementine about ducks” it works just fine. But if I do “ask Clementine about the ducks” it gives the default response for a topic not in the table.
Surely there must be a way to get the parser to take both “ducks” and “the ducks” without extending the topic to include all the permutations that include the word “the,” yes?
I have tried putting [the] in front of the whole topic list in that row, but that throws an error. I see nowhere to interject “the” into the code:

Instead of asking Clementine about a topic:
	If topic understood is a topic listed in the Table of Clementine Conversation:
		say "[response entry][line break]";
	Otherwise:
		say "'I dunno, I'm just a kid.'".

I’m baffled by this one, and can’t find anything in the manual about it. Trying to scour example code to find instances of this seems a Sisyphean chore. And there’s a bunch of these sorts of topics in several conversation tables.

Topics are matched like understanding tokens. So the correct syntax for optional words is:

"the/-- ducks/ducklings/duck/duckling/birds/bird"

I’m not sure if there’s a better way to do this sort of thing using default rules. You could change it to do substring matches instead:

Table of Clementine Conversation
text	response
"bird"	"They're so cute, aren't they? I better get them to the river for a swim."
"duck"	"They're so cute, aren't they? I better get them to the river for a swim."

Instead of asking Clementine about a topic:
	repeat through Table of Clementine Conversation:
		if topic understood matches the text text entry, case insensitively:
			say "[response entry][line break]" instead;
	say "'I dunno, I'm just a kid.'".

This will match any topic that contains a substring of duck, including ducks, duckling, the Ducklord, and boonduck, so it might be too general for some words. This also is not a topic parser so you can only have one word/substring per row – you may have spotted that it’s in a text column instead of a topic column.

If you’re familiar with regexes, that’s a method you could use to have a single row that matches multiple words and better constrains which alternatives it will accept – see WI§20.6 for more details. They’re not for the faint of heart, however, and may be quite slow if you have a lot of possible responses.

If you’re planning to have quite a bit of conversation in your story, you should probably look into using a conversation extension of some kind. The built-in stuff is fairly primitive. Extensions let you have conversation menus, or define responses based on topics that you can create and give parseable aliases like regular objects, or discuss regular objects as well, or all sorts of other things.

2 Likes

Ahh. That’s better. Thank you very much @mirality
Incidentally, do you know offhand where I might find such info in the manual(s)? I sure couldn’t. Nor could I really figure out how to search for such a thing, seeing how much ‘the’ matches LOL

It’s in WI§11.3 and also WI§17.12.

FWIW, you might also want to have a look at the examples listed in WI§16.13; they include a similar method of looking up responses in tables, but using a slightly different comparison that I hadn’t noticed before, that might be better than the above.

1 Like

Thanks much. I’m still working my way through the manual. Kinda writing and referencing as i go along.
I also recently (FINALLY! :slight_smile:) bought Reed’s “Creating Interactive Fiction with Inform 7,” but have been focusing on the manual more. And then there’s Aiken’s “Inform 7 Handbook” which is nice and useful, but only goes so far.

FYI, here’s the full version of those rules switched back to using a topic parser but with a more-flexible match (from WI§16.13):

Table of Clementine Conversation
topic	response
"ducks/ducklings/duck/duckling/birds/bird"	"They're so cute, aren't they? I better get them to the river for a swim."

Instead of asking Clementine about a topic:
	repeat through Table of Clementine Conversation:
		if topic understood includes topic entry:
			say "[response entry][line break]" instead;
	say "'I dunno, I'm just a kid.'".

This will match duck, the ducks, and The Mighty Duck, but not boonduck. You do still have to list both the singular and plural forms if you want it to match both, though, because it matches entire words (or phrases consisting of consecutive words).

1 Like