ThinkThen

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

choose selects one option.

The talk's slide: choose selects one option.
The four faces: United Press International photo of the Beatles in New York, 7 February 1964, via the Library of Congress and Wikimedia Commons. Public domain in the US. Open the slide at full size.

choose is a switch statement that reads. You list the options, and Jev puts a probability on each. The top option is the pick.

Run it

Every song gets a pick.
is_a_song="The text is the title of a song by the Beatles."
question="$is_a_song Who sings the lead vocal on it?"
singers=(
  John
  Paul
  George
  Ringo
  "John and Paul duet"
)

cat <<'EOF' |
Come Together
Yesterday
Something
Octopus's Garden
She Loves You
EOF
thinkthen choose "$question" "${singers[@]}" \
  --batch 1 \
  --lines \
  --replay recording
Output
{"input":"Come Together","value":"John"}
{"input":"Yesterday","value":"Paul"}
{"input":"Something","value":"George"}
{"input":"Octopus's Garden","value":"Ringo"}
{"input":"She Loves You","value":"John"}
exit 0: the run finished

Change the bar

Under a bar of 0.5, She Loves You is not sure.
is_a_song="The text is the title of a song by the Beatles."
question="$is_a_song Who sings the lead vocal on it?"
singers=(
  John
  Paul
  George
  Ringo
  "John and Paul duet"
)

cat <<'EOF' |
Come Together
Yesterday
Something
Octopus's Garden
She Loves You
EOF
thinkthen choose "$question" "${singers[@]}" \
  --batch 1 \
  --lines \
  --threshold 0.5 \
  --replay recording
Output
{"input":"Come Together","value":"John"}
{"input":"Yesterday","value":"Paul"}
{"input":"Something","value":"George"}
{"input":"Octopus's Garden","value":"Ringo"}
{"input":"She Loves You","value":null}
exit 0: the run finished

The lesson

John and Paul sing She Loves You together. Jev's pick of John does not reach 0.5. The bar turns it into not sure. The four sure picks stay the same, and all four are right.

A bar keeps the sure picks and hands a person the weak one.