Relationship pairs between tiddlers

180 views
Skip to first unread message

Mooglegirl

unread,
Feb 5, 2020, 10:57:41 PM2/5/20
to tiddl...@googlegroups.com
I have tiddlers for different characters in my story, and I want to define a list of pair relationships with accompanying comments, and then generate the relationships for a given character on the fly. For example, I might have some hidden tiddler with something like:

alice:bob (brother/sister)
bob
:carlos (friends)
bob
:darren (rivals)
darren
:alice (boyfriend/girlfriend)

Then on Bob's character page, there would be an automatically generated list that looks something like:
  • Alice (brother/sister)
  • Carlos (friends)
  • Darren (rivals)
How would I go about this?

TonyM

unread,
Feb 6, 2020, 2:09:08 AM2/6/20
to TiddlyWiki
have you thought of being more specific like;

Each character eg; has a sister field containing Alice etc... (better sibling as below)
Field for friends, rivals and partners field as well, ideally each can have multiple values such as friends
I suggest a sibling field containing brothers and or sisters and by having a gender on each person a sibling who is a female is a sister.

Then you could have a tiddler tagged view template that appears on each person tiddler and uses the fields on the person or search for the fields on other persons containing their name.

Also with Marios GenTags plugin you could create separate tag fields for each "relationship".

See recent discussions on similar subjects
  • How to model relationships between tiddlers
  • The TiddlyBlink edition does something similar
Feel free to ask for more help

Regards
Tony

Mooglegirl

unread,
Feb 6, 2020, 9:06:40 AM2/6/20
to TiddlyWiki
I'd rather not do it on the character pages themselves since that'd either make me edit the relationships in two places, or have to go hunting for which page the relationship is defined on. At that point I'd rather just list them manually.

Getting more specific wouldn't really work either since I'd have to make a new field every time a new relationship type comes up, and there could be unique ones out there.

Were those two bullets supposed to be links? They're not working for me, sorry 😅

Eric Shulman

unread,
Feb 6, 2020, 9:32:05 AM2/6/20
to TiddlyWiki
On Wednesday, February 5, 2020 at 7:57:41 PM UTC-8, Mooglegirl wrote:
I have tiddlers for different characters in my story, and I want to define a list of pair relationships with accompanying comments, and then generate the relationships for a given character on the fly. For example, I might have some hidden tiddler with something like:

alice:bob (brother/sister)
bob
:carlos (friends)
bob
:darren (rivals)
darren
:alice (boyfriend/girlfriend)


There is a fundamental flaw in your intended design:  in a DictionaryTiddler, which contains key:value pairs, each key must be unique, but in your example, you have two separate entries both with a key of "bob".

To see the problem, try this on Tiddlywiki.com:

1) Create a tiddler (e.g., "MyData") containing the example content shown in your post and set the type of the tiddler to "application/x-tiddler-dictionary"
2) Create another tiddler (e.g., "MyTest") containing: {{MyData##bob}}

Notice that only one result is shown: "darren (rivals)".

To achieve the kind of design you want, you would have to make each key value unique (e.g., "bob-friends" and "bob-rivals"), but then it would be problematic to do a lookup for the "Bob" tiddler.  You would have to get the list of all key names and remove any "-friends" and "-rivals" suffix to find the desired key entries, and then restore those suffices when you want to actually fetch the corresponding value for each matching key.  The required code is complex and prone to errors in implementation.

You might be able to address the problem by having separate DictionaryTiddlers for each type of relationship.  Thus, you would have a "Friends" tiddler containing "Bob:Carlos" and a "Rivals" tiddler containing "Bob:Darren".  Of course, this has it's own complexities, in that you would have to check every relationship tiddler to find and display any entries for "Bob".

-e

Mooglegirl

unread,
Feb 6, 2020, 9:37:12 AM2/6/20
to TiddlyWiki
It doesn't have to be a dictionary, I just used that formatting as an example 🤔 In fact it doesn't have to be an existing data structure at all, if there's a way for me to parse the raw text on my relationship tiddler (even if that means getting my hands dirty with Javascript).

Diego Mesa

unread,
Feb 6, 2020, 10:10:01 AM2/6/20
to TiddlyWiki
Hello,

I asked a very related question some time ago:


and have not yet found a satisfactory result

Mooglegirl

unread,
Feb 6, 2020, 11:58:46 AM2/6/20
to TiddlyWiki
I managed to get this working with a JS macro:

(function() {

exports.name = "getRelationships";

exports.params = [
  {name: "targetPerson"}
];

exports.run = function(targetPerson) {
  var relationships = this.wiki.getTiddlerText("Relationship Map").split("\n");
  var result = "";

  for(var i = 0; i < relationships.length; i++) {
    var current = relationships[i];
    if(current.indexOf(":") > 0 && current.indexOf("|") > 0) {
      var people = current.split("|")[0].trim().split(":");
      var note = current.split("|")[1].trim();
      if(people.includes(targetPerson)) {
        var otherPerson = people[1 - people.indexOf(targetPerson)];
        result += "[[" + otherPerson + "]] (" + note + ")\n";
      }
    }
  }

  return '"""' + result + '"""';
};

})();

My Relationship Map tiddler looks like this, with a type of text/plain:

Sarah Gallo:Bob Vurto | teammates, friends
Carl Savette:Sarah Gallo | teammates, co-leaders
Frank Gordman:Robert Daloa | best friends, teammates

And then I call it on the character page (ex: Sarah Gallo) like this:

<$macrocall $name="getRelationships" targetPerson={{!!title}}/>

Assuming the names listed in the Relationship Map are the same as the titles of the character tiddlers, this works great 👍 The only trade-off is that if I modify the Relationship Map, I have to reload the whole wiki (since the script has already run).

Mark S.

unread,
Feb 6, 2020, 12:10:47 PM2/6/20
to TiddlyWiki
 Tony's suggestion is best, if you want to have usable information that will let you extract information or find emergent relations.

I'd rather not do it on the character pages themselves since that'd either make me edit the relationships in two places, or have to go hunting for which page the relationship is defined on. At that point I'd rather just list them manually.

What you would do is create a relationship generator. You'd pick Character A from one drop down list, Character B from the next, the type of relationship from another, and press a button.
Character A would be added to B's relationship, and vice versa.

This is pretty much how all automation problems are handled. People are unreliable at data entry, so they need a framework in order to make sure that mistakes are avoided.

Getting more specific wouldn't really work either since I'd have to make a new field every time a new relationship type comes up, and there could be unique ones out there.


Just add another relationship to the generator.

Doing it your way, as a simple list, you might forget relationships (was he an enemy, a rival, or a frenemy?)

If you really wanted to do it as a list, then you would probably need JSON. So your list would look more like:


{ "alice":
     {
      "brothers" : {"bob"},
      "gender" : "female",
      "so" : {"darren" }
     } ,
   "bob" :
     {
       "sisters" : {"alice"},
       "gender"  : "male"
     } ,
   "carlos" :
     {
      "friends" : {"carlos"} ,
      "rivals"  : {"darren" }
     } ,
    "darren"
:
      {
        "so" : {"alice" } ,
        "gender" : "male" 
      }
}


Unfortunately, TW can't parse JSON more than one level, so you would need Joshua Fontany's JSON mangler https://joshuafontany.github.io/TW5-JsonMangler/ to extract the data.



Mat

unread,
Feb 6, 2020, 12:30:21 PM2/6/20
to TiddlyWiki
So here's a rough setup where each character is a tiddler and it has fields on the form

title: derren
tags: character
love: alice
rivals: bob

http://twable.tiddlyspot.com/

It could easily be extended in functionality.

<:-)

TonyM

unread,
Feb 6, 2020, 5:05:49 PM2/6/20
to TiddlyWiki
Moogirl,


Getting more specific wouldn't really work either since I'd have to make a new field every time a new relationship type comes up, and there could be unique ones out there.

If you have an effective solution you need not create any fields manually and it happens with the act of naming the person with the relationship. A little forethought could predict all possible relationships, especially if you have a catch all. But a little smart design you could add additional relationship fields to the design easily, but these will only be created as needed for a give person.  By permitting multiple people in any given relationship field you need one for all siblings as an example, you could have acquaintances etc...  

It is also possible to for example search all sibling fields for those containing the current Persons name. This would allow you to see the other people who have nominated the current person as their sibling so you need only state this relationship in one tiddler.

Although you may find it valuable to be able to alter the nature of the relationship from a different persons perspective. It could show gaps in what the text assumes the reader is aware of, perhaps useful in murder mysteries. 

Were those two bullets supposed to be links? They're not working for me, sorry 😅
No they were just search opportunities - I spent some time trying to find appropriate links, thought I would leave it to you.

Some of us here would help you achieve your goal if you want.

Personally I am interested in establishing one to one, one to many, two way relationships between tiddlers, However I would like to add a feature where by the relationship is established/broken at a point in time, for genealogical reasons, for example marriage can have a start and end date

You may be interesting in making use of the references and backlinks in the Info button, which atotolinkk to tiddlers where the current is "mentioned" or use of these in other forms, this is what is part of tiddlyblink
 
Regards
Tony

Jed Carty

unread,
Feb 8, 2020, 4:49:11 AM2/8/20
to TiddlyWiki
Mooglegirl,

I think that the best data structure conceptually for what you are describing is a directed graph. Directed because you could have 'siblings' which is undirected but you could also have brother and sister which each only go one way between the pair.

In a more concrete sense you would make one tiddler for each node, in this case a node represents a character, and then other tiddlers define the edges of the graph, which represent the relationships.

As a bit of theory for tiddlywiki, one thing I have consistently struggled with in tiddlywiki is an incorrect idea of what complexity means in the context of tiddlywiki. Having hundreds of tiddlers isn't necessarily more complex than having 10 tiddlers that have a lot of internal structure. So I would go for something that uses many tiddlers and gives exactly what you want instead of something more compact that uses fewer tiddlers but is more complex.

An only slightly relevant example is the contacts database that I made a while ago, you can see an example here (http://inmysocks.tiddlyspot.com/#%24%3A%2Fplugins%2Finmysocks%2FDashboard%2FDashboard), I have a dedicated demo site somewhere but I don't have the link handy.

Anyway, something with a similar structure to the contacts may be a reasonable way to organise your characters and make it reasonable to modify relations and add/remove characters. If I have time later today I will try to put an example together that may make more sense than the contacts structure.
Reply all
Reply to author
Forward
0 new messages