ThinkThen

Beatles Bench pages
Scripts
What Jev knows
Tune your bar
Beatles Bench · The ten functions

relate asks what Jev knows about the names.

The talk's slide: relate asks what Jev knows about the names.
The slide shows the talk's run, which asked one yes or no question for each pair. The example below marks the song-to-album rule single, so it asks one menu for each song. Open the slide at full size.

relate gets a list of names and their kinds, and no text. Jev answers from what it knows. recognize --relation links names by what a text states.

Here four people, five songs, and three albums go in. The rules file names two relations. sings runs from a person to a song, and it asks one yes or no question for each pair. One person sings the lead on many songs. on_album runs from a song to an album. A song first appears on one album, so the rule says "single": true. It asks one menu for each song: which listed album, or none of these. Every answer at 0.5 or more comes out as an edge.

names.jsonl, the names in
{"name":"John Lennon","kind":"person"}
{"name":"Paul McCartney","kind":"person"}
{"name":"George Harrison","kind":"person"}
{"name":"Ringo Starr","kind":"person"}
{"name":"Come Together","kind":"song"}
{"name":"Yesterday","kind":"song"}
{"name":"Something","kind":"song"}
{"name":"Taxman","kind":"song"}
{"name":"Octopus's Garden","kind":"song"}
{"name":"Help!","kind":"album"}
{"name":"Revolver","kind":"album"}
{"name":"Abbey Road","kind":"album"}
rules.json, the two rules
{
  "version": 1,
  "relate": {
    "relations": [
      {
        "name": "sings",
        "source": "person",
        "target": "song",
        "reads": "sings the lead vocal on"
      },
      {
        "name": "on_album",
        "source": "song",
        "target": "album",
        "reads": "is on the album",
        "single": true
      }
    ]
  }
}

Run it

Nine edges come out at the default bar of 0.5. Each song gets one album.
thinkthen relate @rules.json \
  --jsonl \
  --input names.jsonl \
  --replay recording |
jq -c '[.source.name, .relation,
  .target.name, .probability]'
Output
["John Lennon","sings","Come Together",0.8]
["Paul McCartney","sings","Yesterday",0.84]
["George Harrison","sings","Something",0.89]
["Ringo Starr","sings","Octopus's Garden",0.94]
["Come Together","on_album","Abbey Road",1.0]
["Yesterday","on_album","Help!",0.62]
["Something","on_album","Abbey Road",0.98]
["Taxman","on_album","Revolver",0.97]
["Octopus's Garden","on_album","Revolver",0.91]
exit 0

Change the bar

At 0.8, eight edges stay.
thinkthen relate @rules.json \
  --jsonl \
  --input names.jsonl \
  --threshold 0.8 \
  --replay recording |
jq -c '[.source.name, .relation,
  .target.name, .probability]'
Output
["John Lennon","sings","Come Together",0.8]
["Paul McCartney","sings","Yesterday",0.84]
["George Harrison","sings","Something",0.89]
["Ringo Starr","sings","Octopus's Garden",0.94]
["Come Together","on_album","Abbey Road",1.0]
["Something","on_album","Abbey Road",0.98]
["Taxman","on_album","Revolver",0.97]
["Octopus's Garden","on_album","Revolver",0.91]
exit 0

The lesson

One of the nine edges is wrong. Jev puts Octopus's Garden on Revolver at 0.91. It first appeared on Abbey Road. No edge says who sings Taxman. George sings it, and Jev's answer fell under the bar. At 0.8, Yesterday on Help! drops out at 0.62, and it is right. The wrong edge stays.

A menu gives each song one album. A bar of 0.8 keeps the confident wrong answer.