I was looking at Auto-appending a field, and thought I might try storing lists of mutual synonyms in a JSON tiddler
title: Synonyms
type: application/json
[
["Delight", "Joy", "Ecstasy"],
["Anxiety", "Stress", "Tension", "Apprehension"],
["Gratitude", "Contentment", "Thankfulness"]
]
But I’m not really sure how I could get the list of matching ones. In JS, I’d just do this:
const getSynonyms = (synonyms, term) =>
synonyms.find(list => list.includes(term)) || []
const synonyms = [
["Delight", "Joy", "Ecstasy"],
["Anxiety", "Stress", "Tension", "Apprehension"],
["Gratitude", "Contentment", "Thankfulness"]
]
getSynonyms(synonyms, 'Stress') //=> ["Anxiety", "Stress", "Tension", "Apprehension"]
My best attempt so far in wikitext is, I believe, not very close:
[{Synonyms}jsonindexes[]] :map[{Synonyms}jsonget<currentTiddler>] :filter[contains[Stress]]
This part, in the Advanced Search, Filter tab:
[{Synonyms}jsonindexes[]] :map[{Synonyms}jsonget<currentTiddler>]
yields the list Delight Anxiety Gratitude
, so it seems too late to add a filter
step.
Can I use jsonget
or something similar to extract a whole list which I can then further process?
Of is there a better way to do this?