Beatles Bench · The ten functions
score can rate on a linear scale you define.
score places a text on a scale you name, lowest level first. It returns a number along that scale. Here the scale runs from about 0 minutes to about 9 minutes, in even steps.
Run it
Each song gets a length in minutes.
is_a_song="The text is the title of a song by the Beatles."
question="$is_a_song How long is the recording?"
minutes=(
"about 0 minutes"
"about 1 minute"
"about 2 minutes"
"about 3 minutes"
"about 4 minutes"
"about 5 minutes"
"about 6 minutes"
"about 7 minutes"
"about 8 minutes"
"about 9 minutes"
)
cat <<'EOF' |
Her Majesty
Yesterday
Octopus's Garden
Something
Come Together
A Day in the Life
Hey Jude
Revolution 9
EOF
thinkthen score "$question" "${minutes[@]}" \
--batch 1 \
--lines \
--replay recordingOutput
{"input":"Her Majesty","value":0.67}
{"input":"Yesterday","value":2.12}
{"input":"Octopus's Garden","value":3.17}
{"input":"Something","value":3.81}
{"input":"Come Together","value":4.34}
{"input":"A Day in the Life","value":4.868686868687}
{"input":"Hey Jude","value":7.07}
{"input":"Revolution 9","value":7.27}exit 0: the run finished
Set the bar
Your code keeps the songs at 5 minutes or more.
is_a_song="The text is the title of a song by the Beatles."
question="$is_a_song How long is the recording?"
minutes=(
"about 0 minutes"
"about 1 minute"
"about 2 minutes"
"about 3 minutes"
"about 4 minutes"
"about 5 minutes"
"about 6 minutes"
"about 7 minutes"
"about 8 minutes"
"about 9 minutes"
)
cat <<'EOF' |
Her Majesty
Yesterday
Octopus's Garden
Something
Come Together
A Day in the Life
Hey Jude
Revolution 9
EOF
thinkthen score "$question" "${minutes[@]}" \
--batch 1 \
--lines \
--replay recording |
jq -c 'select(.value >= 5)'Output
{"input":"Hey Jude","value":7.07}
{"input":"Revolution 9","value":7.27}exit 0
The lesson
score has no threshold. A Day in the Life runs over five minutes. Jev scores it 4.868686868687, and a bar of 5 leaves it out.
A score is a position. Your code draws the line.
On GitHub: github.com/botassembly/beatles-bench/tree/main/examples/score