Skip to content

score

score places a piece of text on a scale of levels you name, from lowest to highest. It prints a number from 0, the lowest level, to 1, the highest.

Terminal window
echo 'Please refund my order.' |
thinkthen score --level routine --level urgent \
'How urgent is the request?'

Output

0.05

Close to 0: a refund request is routine, not urgent.

Terminal window
echo 'I was charged twice for one invoice.' |
thinkthen score --level routine --level urgent \
'How urgent is the request?'

Output

0.45

Higher: a double charge is more urgent than a plain refund request, but still nearer routine than urgent.

See why

--json prints the details. This jq keeps the chance of each level, lowest first.

Terminal window
echo 'Please refund my order.' |
thinkthen score --json --level routine --level urgent \
'How urgent is the request?' |
jq -c '.detail.levels'

Output

[0.95,0.05]

routine has 0.95 and urgent 0.05. The score weighs each level by its place on the scale, so with two levels it is the chance of the higher one. JSON output lists every field.

Use more levels

Name the levels with --level, lowest first. With three levels, the middle one counts as 0.5.

Terminal window
echo 'I was charged twice for one invoice.' |
thinkthen score \
--level routine --level soon --level urgent \
'How urgent is the request?'

Output

0.515

score always prints a number from 0 to 1, however many levels you name.

Score every row of a CSV file
messages.csv
id,text
a1,Please refund my order.
a2,Where is my parcel?
a3,I was charged twice for one invoice.
Terminal window
thinkthen score 'How urgent is the request?' \
--level routine --level urgent \
--from csv --column text --into urgency < messages.csv

Output

id,text,urgency
a1,Please refund my order.,0.05
a2,Where is my parcel?,0.14
a3,I was charged twice for one invoice.,0.45

--column names the column to read, and --into names the new answer column. File types covers TSV, Excel and other files.

Options
OptionWhat it does
<QUESTION>Question to ask
[FILE]...Input files; default: standard input
--name <NAME>Optional execution identity
--text <TEXT>Judge this text instead of reading input
--level <LEVEL>Scale level; repeat low to high
--column <COLUMN>Field column; repeat; replaces a saved pointer
--details [=<DETAILS>]Add status, probability, error, detail and source columns
--in-place [=<IN-PLACE>]Replace source with backup
--into <INTO>Answer field for JSON Lines; column for tables
--output <OUTPUT>Destination path
--sheet <SHEET>Worksheet

Shared options

If score can't answer a text, it prints an error and exits with code 2, 4, 5 or 6. Troubleshooting lists each error and its fix.

In code: Python · TypeScript · Go · Java · Kotlin · C# · R · Ruby · Rust · Swift · Zig · C · C++ · DuckDB · SQLite · PostgreSQL

Next: rank sorts lines from highest to lowest on the same kind of scale.