Auto-appending a field

Hello,

I have “topic” tiddlers that have a field called see-also, in which I add synonyms to. For example, if I have a tiddler called “anxiety”, I may have “stress” in its see-also field.

I collect quotes from books and create a tiddler for each quote. I tie the quote to a topic by typing the topic in a field on the quote tiddler called primary-topic. All works well.

However, what I’d love to be able to do is make it so that if I type “anxiety” in the primary-topic field of a tiddler, upon save it automatically appends the value in the see-also field of the “anxiety” tiddler.

Any ideas on how I can accomplish this?

1 Like

A simple suggestion, at a high level, is to use a temporary tiddler to accept your entry, then on click of a button do what you wish, write it to one or more locations, Set a tiddler to the current tiddler etc… However you could edit the field via a edit or edit text widget and use a button or input action to update your other tiddler. Perhaps with the current tiddler title.

  • As soon as you involve a button, or a way to trigger an action, you can use the range of action widgets to do any amount of processing and setting tiddlers or fields.

Would that be called “bi-directional fielding”? :slight_smile:

So far I have only seen “bi-directional linking” - something that existed in TW from the start but my Stroll experiment made it more obvious and accessible.

Maybe a list filter in the text field (or a viewtemplate tiddler) like <$list filter='[search:primary-topic:literal<currentTiddler>]'><$link/></span><br></$list>?

I agree with @DaveGifford approach, the best way to achieve a bi-directional link is to set it in one direction and use a list filter to find it in the other direction. This means the link is stored in only one place so if changed changes automatically.

Existing operators such as backlinks already demonstrate this at least for the text field.

Yes, that is a drawback of using fields for bi-directional connections instead of links. If you change the contents of a tiddler’s field and it is not listed as a [[link]], there are no easy ways to update it in corresponding tiddlers.

With links you can use the newer RelinkPlugin to automatically update links in any or all fields.

Perhaps I am misunderstanding, but I’m not sure a bi-directional “field” would work because the see-also field on the topic tiddler wouldn’t contain the topic. It would contain essentially synonyms for it. Whereas the primary-topic field on a quote tiddler should contain both the topic and its synonyms.

On bi-directional links

There are two approaches to doing this,

  • Only store the information in one place and use and appropriate filter to retrieve it in the other place. In many ways this is how references and backlinks work. I demonstrate this below.
  • The other is to lean on the relink plugin which is perfectly acceptable although not always necessary.

I have just started with a proof on concept on this wiki https://sandbox-by-tones.tiddlyhost.com/

The icons in the view toolbar are related tiddlers (any number of tiddlers) and related tiddler (One tiddler only, the next selection replaces it).

Snag_4edf07bf

Using the left hand grey button select it and search for a tiddler title and click to add it to the related tiddlers list.

Now open one of the related tiddlers from that same list, and click on the button again, you will see the “related to” list says where every the current tiddler is in another’s related-tiddlers field.

It not yet perfect, any review comments welcome.

  • Does in this example, have a look.
2 Likes

Very tool toys, Tones! I bookmarked this site and hope to play with it soon.

Its more for sharing particular things not a repository but get what you can.

@switchplayer I think the important question is, not how to propagate some value to other tiddlers, but rather why do you want to do it and what do you want to achieve.

If you want to find all tiddlers related to a topic tiddler, it can be achieved through filters, without the topic tiddler necessarily having all the synonyms in its own field.

I would gladly help with achieving that, but I’m not sure I get your example precisely enough. Could you describe what values you would like to input in which fields of which tiddlers? Would it be something like:

title: quote
primary-topic: anxiety stress

title: anxiety
see-also:

And you would like “stress” to appear in “see-also” field of “anxiety” in this situation?

Hey guys, thanks for helping out. I have uploaded a video describing my need. Let me know if this helps clarify!

Thanks for the video, it’s much clearer to me now what you need. After seeing the video I’m convinced that modifying contents of fields on other tiddlers is not the most practical approach. It can definitely be done, but it’s not necessarily worth the effort.

So lets concentrate on achieving what you want without modifying fields of other tiddlers on saving.

1. List all related excerpts in a topic tiddler.

You already have that, probably using a filter like [search:primary-topic:literal<currentTiddler>] to find all excerpts that have the given topic in their primary-topic field.

2. Keeping a list of synonyms

I would suggest keeping the field see-also in TW’s list format, that is space separated and wrapped in [[double square brackets]] if the synonym contains spaces. So for example a valid list would be: red green [[light blue]]. This format works best for further use in filters, plugins, etc.

3. Seeing synonyms of primary-topic in the excerpt tiddler.

[<currentTiddler>get[primary-topic]get[see-also]enlist-input[]] will give you the synonyms of the current excerpt tiddler, taken from the see-also field of the tiddler indicated in its primary-topic. You can use it in a view template applied to the excerpt tiddlers, it looks like you’re already familiar with that.

4. Configure Relink

I recommend you to use Relink anyway for a wiki like that. As mentioned above, Relink will update all references to a tiddler in the recognized places (like links in text field or core macros that take a title as parameter). If you want Relink to recognize your custom structures (fields), you have to define them in the plugins configuration. You would need to add your fields like this:

Then, if you rename the topic tiddler, it will be updated in all excerpts that have it as primary-topic. If you ever create a tiddler for a term listed in see-also, and then rename it, the see-also will be updated as well.


I hope it’s comprehensible and at least a little bit helpful. Ask away if anything is still unclear.

Did you also want that if you add something to the primary-topic in the excerpt, it will also get added to see-also in the topic tiddler? There’s a way of doing that as well, but I wasn’t sure if you need it.

3 Likes

This all makes sense except for one piece…

3. Seeing synonyms of primary-topic in the excerpt tiddler.

What I want here is not necessarily being able to view the synonyms, but have the synonyms literally populated in the primary-topic field.

Let’s, for example, use a topic tiddler called “gratitude”. This tiddler has “thankfulness” in its see-also field (and “thankfulness” is its own topic tiddler with “gratitude” in its see-also field). I create an excerpt tiddler in which its primary topic is gratitude, and thus I put “gratitude” in the excerpt’s primary-topic field. I want to be able to have the field add “thankfulness” to it as well (i.e. appending gratitude’s see-also field). The reason for this is because then I don’t have to worry about always using the right word if there are different words with similar definitions. If I use “gratitude” as the primary-topic, it appends “thankfulness” to it. If I use “thankfulness” as the primary-topic, it appends “gratitude” to it. And then I can look at the gratitude topic tiddler and see all the excerpt tiddlers with it as the primary topic, and I can look at the thankfulness topic tiddler and see all the excerpt tiddlers with it as the primary topic. And these excerpt tiddlers for thankfulness would be the same as the excerpt tiddlers for gratitude.

1 Like

@switchplayer I tried to achieve this with filters and ended up with such a crude thing: aaf.json (3.3 KB) (drop it on tw com or empty, not on your wiki where you have tiddlers with the mentioned titles).

I ended up with some clunky long filters that achieve what’s needed and it’s all partly dependent on proper synonyms in see-also fields anyway.

A new idea has come to my mind. What you’re describing seems indeed to be non trivial using filters as I wanted. Having the field values appended does seem to make sense. But now I have the feeling that maybe the whole data structure could be more practical. You’re describing a situation where a bunch of tiddlers are related to each other (through the topic and see-also fields, let’s assume the fields are auto-appended as you want) instead of being related to any central idea (e.g. through a tag or any field you like).

I mean, instead of annotating the excerpt with any term that first comes to your mind and having TW figure out what is it related to later, you could turn it around, and let TW suggest you what terms (already documented by you) are similar to the term that comes to your mind, so you can choose one of those. There is the great Auto Complete plugin that could help in that.

I think that either your problem can be reduced to tagging (or referencing in other way) all somehow related tiddlers with common tag, e.g. “gratitude-and-similar-concepts”, or this can end up in chained relations/synonyms where everything is related to everything (well, it is in the end :thinking:).

@switchplayer, You can of course take any advice with a grain of salt. Sometimes we just want to do something in the way that feels most intuitive to us.

Still, from an information-design point of view, the approach of making sure that the primary-topic field always has both synonyms (plus any relevant “genus” concepts governing your “species”-level tags, etc.) strikes me as setting you up for redundancy, noise, and extra maintenance down the road.

Whatever functionality it is that you’re accomplishing via the primary-topic field (in terms of what’s visible, clickable, etc.), I suspect you can accomplish that task in a way that leverages a “write-once-read-many” kind of location for this connective information. You could use a dictionary-tiddler with entries for each automatic topic “arrow” (if gratitude, then thankfulness; if thankfulness, then gratitude; if Holland, then Netherlands, if Netherlands, then Holland; if Holland, then Europe (etc.)) Or there could be a tiddler for each arrow’s starting-point — so that a Holland tiddler has a “always-see-also” field with Netherlands and Europe as values, etc.

One benefit of doing it this way is that you can add new relationships (Say, I suddenly realize all the existing tiddlers with biography topic should help me connect to non-fiction, etc.) without the need to go re-edit all the existing tiddlers that already mention biography as a topic. Or, suppose I suddenly regret auto-bloating all the “joy”-topic tiddlers with the added “happiness” and “gladness” and “satisfaction” and “positivity” topics, but I don’t just want simply to delete all occurrences of “happiness” (etc.) since some of those topic choices did make sense in their own right. If any “automatic” topic-chute can be added or subtracted as you develop your solution, then you have permission to learn or change your mind flexibly.

If there’s some functional interface goal that you suppose requires populating each tiddler’s primary-topic field (or any other field!) with any and all automatically-related words, I would gently encourage you to share that challenge here.

Regardless of which structure you choose, I wish you plenty of experiences of gratitude and thankfulness and joy in your TiddlyWiki projects. :pray:

3 Likes

All,

My sincerest appreciation for your help and contributions to my ask.

I think I have decided on the following:

  1. For direct synonyms, I will camelCase the title of a single topic tiddler with each synonym. For instance, instead of having a topic tiddler for “gratitude”, a topic tiddler for “contentment”, and a topic tiddler for “thankfulness”, I’ll have a single topic tiddler for “contentmentGratitudeThankfulness”. Then, by using the Autocomplete plugin, I’ll be able to search any of the three and have this one pop up. In addition, this will (hopefully) eliminate the problem of sometimes choosing one synonym over another and thus having inconsistencies in categorization.

  2. I will also have a see-also field on each topic tiddler. For instance, I may have a topic tiddler called “voluntary”, and it would have a see-also field with a value of “freedom”. I don’t consider these words synonyms, but can see the possibility of a relation between the two. So I would have the see-also field to establish that relation, and thus allow me to be looking at “voluntary” and then go down the “chain” to “freedom”.

Interested to hear yall’s thoughts/criticisms/etc on this!

1 Like

If you’re going to use Auto Complete to enter topics anyway, I’d consider using just a single word/term in the title, and place the synonyms in a separate field. AC can be configured to search both title and synonym field, and then present the suggestions showing words from both fields. So e.g. for a tiddler with title “contentment” with synonyms “gratitude thankfulness” if you type “grat”, the AC popup will show a suggestion “contentment (gratitude, thankfulness)”, or any other format you choose, and then insert [[contentment]]. The advantage is you won’t have such long titles if you add more synonyms. If you’re sure you will never have more than 3–4 synonyms for a single topic, then maybe it also makes sense the way you have written.

Btw, I’m not aware of any advantage of camelCase except for quicker typing of links ([[ ]] not needed, with the right wiki settings). For TW, spaces in titles are not really a problem (see this topic). So in this situation where you assume you won’t remember the titles and want to rely on an auto complete mechanism, you could just as well use spaces or any other punctuation in between.

As to your second point, I think it’s a very good idea to separate what is “identical” and what is “similar”, it should make organizing the ideas much clearer in my view.

1 Like

Bear in mind that autoComplete works in fields too. Using a field will give you a bit more flexibility in setting titles. Setting a viewTemplate with (or without) an edit-text will let you maintain your aliases without have to open the tiddler.

1 Like

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:)