Auto-appending a field

Here is an attempt to do what was suggested here, especially @springer’s point of using a write-once-read-many approach: http://scott.sauyet.com/Tiddlywiki/Demo/UsingSynonyms.html.

For a given Topic, we display the Excerpts tagged with that topic and a list of synonyms for the topic name. There are two templates. The one on by default just lists those topics. But you can toggle between another template with a button in the Overview. The second template shows the excerpts associated with each synonym. They are shown here inside HTML Details elements, but could be displayed however desired.

I didn’t have handy appropriate excerpts, so I used quotations from this API call: https://api.quotable.io/quotes/random?limit=50, and turned them into tiddlers with some custom JavaScript. My list of topics and their synonyms is meant to be just large enough to demonstrate the behavior.

The chief point is the list of Synonyms:

[
  ["Delight", "Joy", "Ecstasy"],
  ["Anxiety", "Stress", "Tension", "Apprehension"],
  ["Gratitude", "Contentment", "Thankfulness"]
]

and the function used to choose the matching synonyms for a word:

\function get.synonyms(term)
[{Synonyms}jsonindexes[]] :map[{Synonyms}jsonextract<currentTiddler>] :filter[jsonget[]match<term>] :map:flat[jsonget[]] +[unique[]] +[sort[]]
\end

Note that I had help from talk.tiddlywiki in creating this function. Thanks everyone!

I cribbed all the Topic definitions from Wikipedia, and reused a few for synonyms they didn’t list separately. (Well, except one: please forgive the earworm in “Delight”! :slight_smile:)