Is there a way to prevent the definite article being printed?

There are occasions when you don’t want the definite article being printed before an object. As an example, I recently needed to use several objects that were defined like this:

Object reading_table "one of the tables" room11
has proper scenery supporter;

I had to give them proper so that the definite article was not printed. Without this, something like LOOK ON or SEARCH would have resulted in:
On the one of the tables is a bottle.

However, this hack fails if the definite article is printed at the start of the sentence using something like the (The) printing rule, as this suppresses capitalisation, resulting in:
one of the tables blah blah.

So, Is there a way to prevent the definite article being printed for an object? Perhaps articles? If articles is the correct approach, then my example code would become:

Object reading_table "tables" room11
with
  articles "" "" "one of the ",
has scenery supporter;

Does that look right? Can I use empty strings?

I’m also interested in this for the player object selfobj.

Would something like this work?

Object tables "tables" Cafeteria
	with    articles "One of the" "one of the" "some",
	        name 'table' 'tables',
	        describe [;
	            if (child(self)) {
	               new_line;
	               print (The) self, ", as always, need to be cleared. On it you can see ";
	               WriteListFrom(child(self), ENGLISH_BIT+TERSE_BIT+FULLINV_BIT+RECURSE_BIT);
	               ".";
	            }
	        ]
has     pluralname supporter static;

That’s not so much preventing it from being printed as it is overriding it wherever it would normally be printed.

No, because:

  • The example I gave was the complete definition of the object. Nothing was left out.
  • ‘one of the tables’ is singular. There is also tables (plural) in the same location. This was only an example of one object taken from some very tricky code. I could (should?) have dreamed up a better example.
  • This does not account for the table being described in the list of objects.
  • This is in PunyInform, so WriteListFrom is not appropriate and I don’t need to use that anyway.
  • Each of the strings in articles needs a trailing space.

However, I think I might be on the right track with the use of the articles property, as you’ve demonstrated here. I’ll do a little experimenting.

In the case of selfobj, that would require a change in the relevant library file or overriding the default player object in every game. Obviously, this issue doesn’t come up very often or authors would have requested a change earlier. Or maybe they just put it in the ‘Too Hard’ basket, turn a blind eye and move on to other things.

You didn’t mention PunyInform or tag the post with it, so I didn’t realize that was a constraint. (I’ve added the tag now.) I did test in normal Inform 6 (with StdLib 6/11), to make sure that it handled the problem cases you mentioned.

Can you describe more about what you’re trying to accomplish with respect to the selfobj, perhaps show some transcript excerpts demonstrating the issue(s)?

You will find the routines CDefArt, DefArt and IndefArt in puny.h. These are the routines which are actually called when you use the print rules The, the and a.

You can use Replace to replace them with your own versions, which will skip the article as needed.

1 Like

It’s not a PunyInform issue. It’s a general Inform 6 issue that applies to the standard library and the PunyInform library, hence no need to tag it as punyinform.

Same issue as the general case, but with an extra complication. Seeing as you raised it, the issue with selfobj is that it’s defined with a short_name of “yourself” and has the proper attribute. As a consequence, if you ever use (The)obj, where obj is the player, you get a strange response. For example, the following chunk of code:

if (second ~= rock)
  print_ret (The)second, " ", (IsntOrArent)second, " hard enough to break the glass.";

produces a response like:

> hit glass with me
yourself aren't hard enough to break the glass.

The definition of selfobj in the standard library is as follows:

Class  SelfClass
  with name ',a' ',b' ',c' ',d' ',e',
        short_name  YOURSELF__TX,
        description [;  return L__M(##Miscellany, 19); ],
        before NULL,
        after NULL,
        life NULL,
        each_turn NULL,
        time_out NULL,
        describe NULL,
        article THE__TX,
        add_to_scope 0,
        capacity 100,
        parse_name 0,
        orders 0,
        number 0,
        narrative_voice 2,
        narrative_tense PRESENT_TENSE,
	nameless true,
        posture 0,
        before_implicit [;Take: return 2;],
  has   concealed animate proper transparent;

SelfClass selfobj "(self object)";

As you can see:

  • It has the proper attribute, so the definite article is suppressed and “yourself” isn’t capitalised.
  • “yourself” should be “you”.

The way I7 handles that case is by adding a special check to the implementation of CDefArt, but that doesn’t truly fix the problem—imagine if the text said “It seems (the) second (IsntOrArent) second hard enough to break the glass”. This would still come out as “yourself”.

1 Like

That might be the way to go. As @fredrik suggested, I could override CDefArt and DefArt (and possibly IndefArt), just to account for selfobj, but it doesn’t account for the general case of preventing printing of the definite article (‘the’) for certain objects, unless I write custom code for every game where this occurs. I know it doesn’t occur very often, but I’ve struck it a couple of times recently. It was only when testing a custom printing rule (the IsntOrArent used in the example), that I discovered the issues with selfobj.

It’s interesting that StdLib 6.12 requires a space at the end of custom strings in the articles property. That’s not the case in StdLib 6/11, and not how usage of the property is shown in DM4. Is this change intentional? If so, it may be designed to support use of empty strings as you propose above.

It’s also interesting that you’re seeing a lower-case “yourself” in the >HIT GLASS WITH ME example. I don’t see that in a test using Inform 6.42 with StdLib 6.12.6 and the print statement you show above. The output is still “Yourself,” but it is capitalized, so there must be a difference in the PunyInform version of CDefArt().

As Draconis points out, it’s not just capitalization that matters in the case of (The) selfobj, there’s also the grammatical role of subject or object – and that isn’t specified by (The) or (the). I thought the “yourself”-vs-“you” problem would be an easy fix in I7 land, but it’s not because of that reason. There’s no way for the compiler to tell what role you intend. (I did manage to get an improvement in the number of correct guesses by peeking at actor, noun and second, but it wasn’t perfect. Any kind of subordinate clause, as with the example from Draconis, requires knowledge of the grammar of the containing sentence, knowledge that is only really available to the author.)

Isn’t it? The example in DM4 §37 IV.2 is

Object "haricot"
  with articles "Le " "le " "un ", ...

(The idea being to support no-space cases like “l’enfant” if necessary.)

I think overriding CDefArt() and DefArt() is still the right solution. I would think of this as replacing the definite articles: “one of the” instead of “the” for this particular object. You could invent a defarticles property which those routines look for.

2 Likes

It is possible that the articles property alone is sufficient – after all, the “haricot” example gives both definite and indefinite articles. But I haven’t experimented with this.

PunyInform doesn’t support articles.

Stdlib gained the ability to capitalize object names at some point. Of course this requires printing to arrays, and this doesn’t work in some (or all?) Infocom z3 interpreters.

I think you already have a set of routines, grammar etc that you tend to add to games you write, to make your games work and look the way you want them to. If you find yourself wanting to skip the article for some objects, just modify CDefart etc to look for a certain attribute or property to control it, and include this code in your games.

2 Likes

So it is! I misremembered based on my experience actually trying it out when I worked through DM4.

I guess StdLib 6/11’s version of PrefaceByArticle() is buggy, then:

[ PrefaceByArticle o acode pluralise capitalise  i artform findout artval;
	if (o provides articles) {
	    artval=(o.&articles)-->(acode+short_name_case*LanguageCases);
	    if (capitalise)
	        print (Cap) artval, " ";	! <-- adds space
	    else
	        print (string) artval, " ";	! <-- adds space
	    if (pluralise) return;
	    print (PSN__) o; return;
	}
...

and StdLib 6/10 and 6/9:

[ PrefaceByArticle o acode pluralise  i artform findout;

   if (o provides articles)
   {   print (string) (o.&articles)-->(acode+short_name_case*LanguageCases),
	       " ";	! <-- adds space
	   if (pluralise) return;
	   print (PSN__) o; return;
   }
...

At the same time, the LanguageArticles array has strings with trailing spaces in all those versions.