Numeric Disambiguation for TADS?

Has anyone shared a solution similar to “Numbered Disambiguation Choices” for Inform 7, for TADS? I know you can write “the first” or “the fifteenth” to select the disambiguation choice presented, but is there code already written and shared out there that makes TADS disambiguation work more like the aforementioned Inform equivalent?

I don’t know of any code that does what you’re asking for. In case you hadn’t already located them, the currently available TADS 3 extensions can be found at http://www.ifarchive.org/indexes/if-archiveXprogrammingXtads3XlibraryXcontributions.

You might just want to look at my SayQuery extension which you can download from there, and in particular the file HyperEnumSugg.t that comes as part of it. This does something like what you’re looking for, but works for picking suggested topics rather than for disambiguation responses. It may nevertheless give you a few ideas.

Alternatively you could try this, which I just lashed together:


modify MessageHelper
    /*
     *   Show a list of objects for a disambiguation query.  If
     *   'showIndefCounts' is true, we'll show the number of equivalent
     *   items for each equivalent item; otherwise, we'll just show an
     *   indefinite noun phrase for each equivalent item.
     */
    askDisambigList(matchList, fullMatchList, showIndefCounts, dist)
    {
        /* show each item */
        for (local i = 1, local len = matchList.length() ; i <= len ; ++i)
        {
            local equivCnt;
            local obj;

            /* get the current object */
            obj = matchList[i].obj_;

            /*
             *   if this isn't the first, add a comma; if this is the
             *   last, add an "or" as well
              */
            if (i == len)
                ", or ";
            else if (i != 1)
                ", ";

            "(<<i>>) "; 
            
            /*
             *   Check to see if more than one equivalent of this item
             *   appears in the full list.
             */
            for (equivCnt = 0, local j = 1,
                 local fullLen = fullMatchList.length() ; j <= fullLen ; ++j)
            {
                /*
                 *   if this item is equivalent for the purposes of the
                 *   current distinguisher, count it
                 */
                if (!dist.canDistinguish(obj, fullMatchList[j].obj_))
                {
                    /* it's equivalent - count it */
                    ++equivCnt;
                }
            }

            /* show this item with the appropriate article */
            if (equivCnt > 1)
            {
                /*
                 *   we have multiple equivalents - show either with an
                 *   indefinite article or with a count, depending on the
                 *   flags the caller provided
                 */
                if (showIndefCounts)
                {
                    /* a count is desired for each equivalent group */
                    say(dist.countName(obj, equivCnt));
                    disambigPreParser.dList += countName(obj, equivCnt);
                }
                else
                {
                    /* no counts desired - show with an indefinite article */
                    say(dist.aName(obj));
                    disambigPreParser.dList += dist.aName(obj);
                }
            }
            else
            {
                /* there's only one - show with a definite article */
                say(dist.theName(obj));
                disambigPreParser.dList += dist.theName(obj);
            }
        }
    }
   
;    

disambigPreParser: StringPreParser
    doParsing(str, which)
    {
        if(which == rmcDisambig && dList.length > 0)
        {
            local i = toInteger(str);
            if(i != nil && i > 0 && i <= dList.length)
            {
                str = dList[i];
                "(<<str>>)\n";
            }
        }
        
        if(which != rmcDisambig)
            dList = [];
        
        return str;
    }
    
    dList = []
;

A quick test suggests it can handle simple cases; it may need more work for more complex ones, but it should suffice to get you started.

Wow, thanks for making this on the spot!