Adding Articles to Room Names Programmatically

Greetings all. I have some code like this:

To say a/an lowercase (item - an object):
	let T be "[an item]";
	say "[T in lower case]".
	
To say the lowercase (item - an object):
	let T be "[the item]";
	say "[T in lower case]".

The code that uses this is:

A room has some text called the unvisited summary.
The unvisited summary of a room is usually "[a lowercase item described]".

Or

A room has some text called the visited summary.
The visited summary of a room is usually "[the lowercase item described]".

The challenge here is that rooms in the source text are listed like this:

Lancaster Walk is a room. "This is the initial descrition of Lancaster Walk."

Notice that it’s not “The Lancaster Walk”. If I do add “The” in the source text, the code works. But I’m curious if I can somehow force a room to be displayed with a definite or indefinite article even if the room doesn’t have such in the source code.

You can, by explicitly saying “the Lancaster Walk is not proper-named”. But it’s easier to just use the article in the source code; when you first declare an object, Inform looks at what article you used, and sets the object’s properties accordingly. If you don’t use any article at all, it assumes it’s a proper noun (like “Durham Cathedral”).

Since presumably you don’t want your code to say “a durham cathedral” and “the durham cathedral”, better to provide Inform the information it wants, which will let it insert the article for common names and leave it off for proper names.

3 Likes

Ah, much thanks! You provided the crucial clue. So I can do this:

To say a/an lowercase (item - an object):
	if the item is a room:
		now the item is not proper-named;
	let T be "[an item]";
	say "[T in lower case]".
	
To say the lowercase (item - an object):
	if the item is a room:
		now the item is not proper-named;
	let T be "[the item]";
	say "[T in lower case]".

The implementation is going to be a little more specific than what I’m showing but that does seem to do the trick.

You can, but if you’re going to override it for every room there’s no real reason to set the property at runtime rather than compile-time, right?

A room is never proper-named.
3 Likes

A fantastically good point and agreed!

I was looking for a solution regarding people’s names, because in Greek the definite article is also used together with names.

The rule A person is never proper-named. worked perfectly in my case!

1 Like

In that case, I’d actually recommend seldom instead of never, which gives the author the freedom to override the library in specific cases if needed. I don’t know if Modern Greek has any of those, but it seldom hurts!

1 Like