From d1dba10e71ba6b0cdbb75d7283bd4c26499bb38d Mon Sep 17 00:00:00 2001 From: Zed Lopez Date: Mon, 30 Mar 2026 18:24:40 -0700 Subject: [PATCH] fixing indefinite article mismatches per I7-2138 (for glulx only) --- .../BasicInformKit/Sections/Printing.i6t | 266 +++++++++--------- .../EnglishLanguageKit/Sections/Language.i6t | 14 +- .../Tests/Test Cases/Articulation-G--I.txt | 56 ++++ .../Tests/Test Cases/Articulation-G--S.txt | 6 + inform7/Tests/Test Cases/Articulation-G.txt | 33 +++ 5 files changed, 243 insertions(+), 132 deletions(-) create mode 100644 inform7/Tests/Test Cases/Articulation-G--I.txt create mode 100644 inform7/Tests/Test Cases/Articulation-G--S.txt create mode 100644 inform7/Tests/Test Cases/Articulation-G.txt diff --git a/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7xd/Materials/Inter/BasicInformKit/Sections/Printing.i6t b/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7xd/Materials/Inter/BasicInformKit/Sections/Printing.i6t index bfce7abe7..5465f421d 100644 --- a/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7xd/Materials/Inter/BasicInformKit/Sections/Printing.i6t +++ b/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7xd/Materials/Inter/BasicInformKit/Sections/Printing.i6t @@ -14,12 +14,12 @@ by having to capitalise the first letter. We do this by writing to the buffer and then altering the first character. = -Constant SHORT_NAME_BUFFER_LEN = 160; #Iftrue CHARSIZE == 1; -! Allow a generous overrun -Array StorageForShortName buffer SHORT_NAME_BUFFER_LEN+90; +Constant SHORT_NAME_BUFFER_LEN = 250; +Array StorageForShortName buffer SHORT_NAME_BUFFER_LEN; #Ifnot; +Constant SHORT_NAME_BUFFER_LEN = 1000; Array StorageForShortName --> SHORT_NAME_BUFFER_LEN; #Endif; @@ -44,10 +44,9 @@ Array StorageForShortName --> SHORT_NAME_BUFFER_LEN; return RunTimeError(2, obj, prop); } } - #Ifdef TARGET_ZCODE; StorageForShortName->WORDSIZE = VM_LowerToUpperCase(StorageForShortName->WORDSIZE); - for (i=WORDSIZE: ii; + VM_PrintBuffer(StorageForShortName, length); #Ifnot; if (length > SHORT_NAME_BUFFER_LEN) length = SHORT_NAME_BUFFER_LEN; if (length) @@ -60,6 +59,7 @@ Array StorageForShortName --> SHORT_NAME_BUFFER_LEN; return; ]; +! No longer used within Printing.i6t [ Cap str nocaps; if (nocaps) print (string) str; else CPrintOrRun(str, 0); @@ -71,52 +71,54 @@ process we print just the name itself (without articles attached), and we do it by carrying out an activity. = -[ PSN__ o; - if (o == 0) { LW_Response('Y'); rtrue; } - switch (metaclass(o)) { - Routine: print ""; rtrue; - String: print ""; rtrue; - nothing: print ""; rtrue; - } - RegardingSingleObject(o); - CarryOutActivity(PRINTING_THE_NAME_ACT, o); +[ PSN__ o i; + if (~~o) { LW_Response('Y'); rtrue; } + switch (metaclass(o)) { + Routine: print ""; rtrue; + String: print ""; rtrue; + nothing: print ""; rtrue; + } + RegardingSingleObject(o); + CarryOutActivity(PRINTING_THE_NAME_ACT, o); ]; -[ PrintShortName obj i; - i = indef_mode; indef_mode = NULL; - PSN__(obj); indef_mode = i; +[ PrintShortName obj; + @push indef_mode; + indef_mode = NULL; + PSN__(obj); + @pull indef_mode; ]; @h Standard Name Printing Rule. + In its initial state, the "printing the name of" activity has just one rule: the following "for" rule. = + Global caps_mode = false; [ STANDARD_NAME_PRINTING_R obj; - obj = parameter_value; - if (obj == 0) { - LW_Response('Y'); return; - } - switch (metaclass(obj)) { - Routine: print ""; return; - String: print ""; return; - nothing: print ""; return; + if (~~parameter_value) { LW_Response('Y'); return; } + obj = parameter_value; + switch (metaclass(obj)) { + Routine: print ""; return; + String: print ""; return; + nothing: print ""; return; } if (obj == player) { - PRINT_PROTAGONIST_INTERNAL_R(); - return; - } + PRINT_PROTAGONIST_INTERNAL_R(); + return; + } if (LanguagePrintShortName(obj)) return; if (indef_mode && obj provides short_name_indef && - PrintOrRun(obj, short_name_indef, true) ~= 0) return; + PrintOrRun(obj, short_name_indef, true) ~= 0) return; if (caps_mode && - obj provides cap_short_name && PrintOrRun(obj, cap_short_name, true) ~= 0) { - caps_mode = false; - return; + obj provides cap_short_name && PrintOrRun(obj, cap_short_name, true) ~= 0) { + caps_mode = false; + return; } - if (obj provides short_name && PrintOrRun(obj, short_name, true) ~= 0) return; + if (obj.&short_name && PrintOrRun(obj, short_name, true) ~= 0) return; print (object) obj; ]; @@ -147,117 +149,125 @@ indefinite singular depends on the text of the object's name. = Global short_name_case; -[ PrefaceByArticle obj acode pluralise capitalise i artform findout artval; - if (obj provides articles) { - artval=(obj.&articles)-->(acode+short_name_case*LanguageCases); - if (capitalise) - print (Cap) artval; - else - print (string) artval; - if (pluralise) return; - print (PSN__) obj; return; - } - - i = GetGNAOfObject(obj); - if (pluralise) { - if (i < 3 || (i >= 6 && i < 9)) i = i + 3; - } - i = LanguageGNAsToArticles-->i; - - artform = LanguageArticles - + 3*WORDSIZE*LanguageContractionForms*(short_name_case + i*LanguageCases); - - switch (LanguageContractionForms) { - 2: if (artform-->acode ~= artform-->(acode+3)) findout = true; - 3: if (artform-->acode ~= artform-->(acode+3)) findout = true; - if (artform-->(acode+3) ~= artform-->(acode+6)) findout = true; - 4: if (artform-->acode ~= artform-->(acode+3)) findout = true; - if (artform-->(acode+3) ~= artform-->(acode+6)) findout = true; - if (artform-->(acode+6) ~= artform-->(acode+9)) findout = true; - default: findout = true; - } +[ PrefaceByArticle obj acode pluralise capitalise i artform findout artval length; + if (obj provides articles) { + artval = (obj.&articles)-->(acode + (short_name_case * LanguageCases)); + if (capitalise) CPrintOrRun(artval); + else print (string) artval; + print " "; + if (pluralise) return; + print (PSN__) obj; + return; + } + i = GetGNAOfObject(obj); + if (pluralise && (i < 3 || (i >= 6 && i < 9))) { i = i + 3; } + i = LanguageGNAsToArticles-->i; + + artform = LanguageArticles + ARTBLOCK_LEN * WORDSIZE * LanguageContractionForms * (short_name_case + i * LanguageCases); + + findout = ((LanguageContractionForms > 4 || LanguageContractionForms < 2) || + (artform-->acode ~= artform-->(acode+ARTBLOCK_LEN)) || + ((LanguageContractionForms >= 3) && (artform-->(acode+ARTBLOCK_LEN) ~= artform-->(acode+(2*ARTBLOCK_LEN)))) || + ((LanguageContractionForms == 4) && (artform-->(acode+(2*ARTBLOCK_LEN)) ~= artform-->(acode+(3*ARTBLOCK_LEN))))); + if (findout) { #Ifdef TARGET_ZCODE; - if (standard_interpreter ~= 0 && findout) { - StorageForShortName-->0 = SHORT_NAME_BUFFER_LEN; - @output_stream 3 StorageForShortName; - if (pluralise) print (number) pluralise; else print (PSN__) obj; - @output_stream -3; - acode = acode + 3*LanguageContraction(StorageForShortName + 2); - } + if (pluralise) { length = VM_PrintToBuffer(StorageForShortName, SHORT_NAME_BUFFER_LEN, LanguageNumber, pluralise); } + else { length = VM_PrintToBuffer(StorageForShortName, SHORT_NAME_BUFFER_LEN, PSN__, obj); } + acode = acode + ARTBLOCK_LEN * LanguageContraction(StorageForShortName + 2); #Ifnot; ! TARGET_GLULX - if (findout) { - if (pluralise) - Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, EnglishNumber, pluralise); - else - Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, PSN__, obj); - acode = acode + 3*LanguageContraction(StorageForShortName); + if (pluralise) { + length = Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, LanguageNumber, pluralise); } - #Endif; ! TARGET_ - - Cap (artform-->acode, ~~capitalise); ! print article - if (pluralise) return; - print (PSN__) obj; + else { + length = Glulx_PrintAnyToArrayUni(StorageForShortName, SHORT_NAME_BUFFER_LEN, PSN__, obj); + } + if (length > SHORT_NAME_BUFFER_LEN) length = SHORT_NAME_BUFFER_LEN; + acode = acode + ARTBLOCK_LEN * LanguageContraction(StorageForShortName); + #Endif; ! TARGET_GLULX + } + + print (string) artform-->acode; + if (pluralise) return; + + #ifdef TARGET_GLULX; + if (findout) glk_put_buffer_uni(StorageForShortName, length); + #ifnot; ! TARGET_ZCODE + print (PSN__) obj; + #endif; ]; @h Object Names III. The routines accessible from outside this segment. = -[ IndefArt obj i s; - if (obj == 0) { LW_Response('Y'); rtrue; } - i = indef_mode; indef_mode = true; s = self; self = obj; - if (obj has proper) { indef_mode = NULL; print (PSN__) obj; indef_mode = i; self = s; return; } - if ((obj provides article) && (TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE) ~= 0)) { - PrintOrRun(obj, article, true); print " ", (PSN__) obj; indef_mode = i; self = s; - return; - } - PrefaceByArticle(obj, 2); indef_mode = i; self = s; +[ IndefArt obj; + if (~~obj) { LW_Response('Y'); rtrue; } + @push indef_mode; + @push self; + indef_mode = true; + self = obj; + if (obj has proper) { + indef_mode = NULL; + print (PSN__) obj; + } + else if ((obj provides article) && (TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE))) { + PrintOrRun(obj, article, true); + print " ", (PSN__) obj; + } + else { PrefaceByArticle(obj, INDEFART_INDEX); } + @pull self; + @pull indef_mode; ]; -[ CIndefArt obj i s; - if (obj == 0) { LW_Response('X'); rtrue; } - i = indef_mode; indef_mode = true; s = self; self = obj; - if (obj has proper) { - indef_mode = NULL; - caps_mode = true; - print (PSN__) obj; - indef_mode = i; - caps_mode = false; - self = s; - return; - } - if ((obj provides article) && (TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE) ~= 0)) { - TEXT_TY_Say_Capitalised(obj.article); print " ", (PSN__) obj; indef_mode = i; self = s; - return; - } - PrefaceByArticle(obj, 2, 0, 1); indef_mode = i; self = s; +[ CIndefArt obj; + if (~~obj) { LW_Response('X'); rtrue; } + @push indef_mode; + @push self; + indef_mode = true; + self = obj; + if (obj has proper) { + indef_mode = NULL; + caps_mode = true; +! print "CIA->P"; + print (PSN__) obj; + caps_mode = false; + } + else if ((obj provides article) && TEXT_TY_Compare(obj.article, EMPTY_TEXT_VALUE)) { + TEXT_TY_Say_Capitalised(obj.article); + print " ", (PSN__) obj; + } + else { + PrefaceByArticle(obj, CINDEFART_INDEX, 0, 1); ! (obj, acode, pluralise, capitalise) + } + @pull self; + @pull indef_mode; ]; -[ DefArt obj i s; - i = indef_mode; indef_mode = false; s = self; self = obj; - if ((~~obj ofclass Object) || obj has proper) { - indef_mode = NULL; print (PSN__) obj; indef_mode = i; self = s; - return; - } - PrefaceByArticle(obj, 1); indef_mode = i; self = s; +[ DefArt obj; + @push indef_mode; + @push self; + indef_mode = false; + self = obj; + if ((~~obj ofclass Object) || obj has proper) print (PSN__) obj; + else PrefaceByArticle(obj, DEFART_INDEX); + @pull self; + @pull indef_mode; ]; [ CDefArt obj i s; - i = indef_mode; indef_mode = false; s = self; self = obj; - if ((obj ofclass Object) && (obj has proper || obj == player)) { - indef_mode = NULL; - caps_mode = true; - print (PSN__) obj; - indef_mode = i; - caps_mode = false; - self = s; - return; - } - if ((~~obj ofclass Object) || obj has proper) { - indef_mode = NULL; print (PSN__) obj; indef_mode = i; self = s; - return; - } - PrefaceByArticle(obj, 0); indef_mode = i; self = s; + @push indef_mode; + @push self; + indef_mode = NULL; + self = obj; + if ((obj ofclass Object) && (obj has proper || obj == player)) { + caps_mode = true; + print (PSN__) obj; + caps_mode = false; + } + else if ((~~obj ofclass Object) || obj has proper) print (PSN__) obj; + else { PrefaceByArticle(obj, CDEFART_INDEX, 0, 1); } + @pull self; + @pull indef_mode; ]; @h Printing in number bases. diff --git a/inform7/Internal/Extensions/Graham Nelson/English Language.i7xd/Materials/Inter/EnglishLanguageKit/Sections/Language.i6t b/inform7/Internal/Extensions/Graham Nelson/English Language.i7xd/Materials/Inter/EnglishLanguageKit/Sections/Language.i6t index ea9eca6cc..1975c8770 100644 --- a/inform7/Internal/Extensions/Graham Nelson/English Language.i7xd/Materials/Inter/EnglishLanguageKit/Sections/Language.i6t +++ b/inform7/Internal/Extensions/Graham Nelson/English Language.i7xd/Materials/Inter/EnglishLanguageKit/Sections/Language.i6t @@ -185,18 +185,24 @@ Constant LanguageCases = 1; ! The number of article cases; English has one Array LanguageArticles --> - ! Contraction form 0: Contraction form 1: - ! Cdef Def Indef Cdef Def Indef + ! Contraction form 0: Contraction form 1: + ! Cdef Def CIndef Indef Cdef Def CIndef Indef - "The " "the " "a " "The " "the " "an " ! Case 0, articles 0 - "The " "the " "some " "The " "the " "some "; ! Case 0, articles 1 + "The " "the " "A " "a " "The " "the " "An " "an " ! Articles 0 + "The " "the " "Some " "some " "The " "the " "Some " "some "; ! Articles 1 ! a i ! s p s p ! m f n m f n m f n m f n Array LanguageGNAsToArticles --> 0 0 0 1 1 1 0 0 0 1 1 1; +Constant CDEFART_INDEX = 0; +Constant DEFART_INDEX = 1; +Constant CINDEFART_INDEX = 2; +Constant INDEFART_INDEX = 3; +Constant ARTBLOCK_LEN = 4; + @h Commands. `LanguageVerbLikesAdverb` is called by `PrintCommand` when printing an `UPTO_PE` error or an inference message. Words which are intransitive verbs, i.e., diff --git a/inform7/Tests/Test Cases/Articulation-G--I.txt b/inform7/Tests/Test Cases/Articulation-G--I.txt new file mode 100644 index 000000000..be8261645 --- /dev/null +++ b/inform7/Tests/Test Cases/Articulation-G--I.txt @@ -0,0 +1,56 @@ + + + + +Articulation +An Interactive Fiction by Zed Lopez +Release 1 / Serial number 160428 / Inform 7 v10.2.0 / D + +Lab +You can see a green traffic signal, an open book, an ostrich, a cat, some eggs, some magic beans, The Man with No Name, Les Misérables, and some water here. + +>** l +Lab +You can see an amber traffic signal, an open book, an ostrich, a cat, some eggs, some magic beans, The Man with No Name, Les Misérables, and some water here. + +>** l +Lab +You can see a red traffic signal, an open book, an ostrich, a cat, some eggs, some magic beans, The Man with No Name, Les Misérables, and some water here. + +>** l +Lab +You can see a green traffic signal, an open book, an ostrich, a cat, some eggs, some magic beans, The Man with No Name, Les Misérables, and some water here. + +>** l +Lab +You can see an amber traffic signal, an open book, an ostrich, a cat, some eggs, some magic beans, The Man with No Name, Les Misérables, and some water here. + +>** l +Lab +You can see a red traffic signal, an open book, an ostrich, a cat, some eggs, some magic beans, The Man with No Name, Les Misérables, and some water here. + +>** review +In review: +yourself: [ singular-named ; proper-named ; indefinite article: ''] + You | You | You | yourself | yourself | yourself +green traffic signal: [ singular-named ; improper-named ; indefinite article: ''] + The amber traffic signal | A red traffic signal | A green traffic signal | the amber traffic signal | a red traffic signal | a green traffic signal +open book: [ singular-named ; improper-named ; indefinite article: ''] + The open book | An open book | An open book | the open book | an open book | an open book +ostrich: [ singular-named ; improper-named ; indefinite article: ''] + The ostrich | An ostrich | An ostrich | the ostrich | an ostrich | an ostrich +cat: [ singular-named ; improper-named ; indefinite article: ''] + The cat | A cat | A cat | the cat | a cat | a cat +eggs: [ plural-named ; improper-named ; indefinite article: ''] + The eggs | Some eggs | Some eggs | the eggs | some eggs | some eggs +magic beans: [ plural-named ; improper-named ; indefinite article: ''] + The magic beans | Some magic beans | Some magic beans | the magic beans | some magic beans | some magic beans +The Man with No Name: [ singular-named ; proper-named ; indefinite article: ''] + The Man with No Name | The Man with No Name | The Man with No Name | The Man with No Name | The Man with No Name | The Man with No Name +Les Misérables: [ plural-named ; proper-named ; indefinite article: ''] + Les Misérables | Les Misérables | Les Misérables | Les Misérables | Les Misérables | Les Misérables +water: [ singular-named ; improper-named ; indefinite article: 'some'] + The water | Some water | Some water | the water | some water | some water + +> + diff --git a/inform7/Tests/Test Cases/Articulation-G--S.txt b/inform7/Tests/Test Cases/Articulation-G--S.txt new file mode 100644 index 000000000..f13e69343 --- /dev/null +++ b/inform7/Tests/Test Cases/Articulation-G--S.txt @@ -0,0 +1,6 @@ +l +l +l +l +l +review diff --git a/inform7/Tests/Test Cases/Articulation-G.txt b/inform7/Tests/Test Cases/Articulation-G.txt new file mode 100644 index 000000000..7d6cc79de --- /dev/null +++ b/inform7/Tests/Test Cases/Articulation-G.txt @@ -0,0 +1,33 @@ +Test: Articulation +For: Glulx + +"Articulation" by "Zed Lopez" + +Use serial comma. +Use command line echoing. + +Lab is a room. + +A traffic signal is in the Lab. +Before printing the name of the traffic signal, say "[one of]green[or]amber[or]red[cycling] ". + +A book is in the lab. The book can be open. The book is open. +Before printing the name of the open book: say "open ". + +An ostrich is an animal in the Lab. [ singular, improper, vowel ] +An animal called a cat is in the Lab. [ singular, improper, consonant ] +The eggs are a plural-named thing in the Lab. [ plural, improper, vowel ] +Some magic beans are in the Lab. [ plural, improper, consonant ] +A man called The Man with No Name is in the Lab. [ singular, proper ] +Les Misérables are plural-named people in the Lab. [ plural, proper ] +The water is in the Lab. The indefinite article is "some". [ singular, improper, "some" ] + +Reviewing is an action applying to nothing. +Understand "review" as reviewing. + +Carry out reviewing: + say "In review:[line break]"; + repeat with t running through things in the Lab begin; + say "[t]: [bracket] [if t is singular-named]singular[else]plural[end if]-named ; [if t is improper-named]im[end if]proper-named ; indefinite article: ['][indefinite article of t]['][close bracket][line break]"; + say " [The t] | [A t] | [An t] | [the t] | [a t] | [an t][line break]"; + end repeat;