tag
tag checks each label in your list against a piece of text and prints every label that fits, separated by tabs. A text may get several labels, one, or none.
echo 'I was charged twice and my parcel is late again.' | thinkthen tag --label billing --label shipping \ 'Which topics appear?'Output
billing shipping
Both labels: the message is about a double charge and a late parcel.
One label
Section titled “One label”echo 'Please refund my order.' | thinkthen tag --label billing --label shipping \ 'Which topics appear?'Output
billing
billing only: the message asks for money back and says nothing about a delivery.
No label
Section titled “No label”echo 'Morgan works for Example Group.' | thinkthen tag --label billing --label shipping \ 'Which topics appear?'Output
(an empty line)
No label fits, so the answer is empty.
See why
Section titled “See why”See why
--json prints the details. This jq keeps the chance of each label.
echo 'I was charged twice and my parcel is late again.' | thinkthen tag --json --label billing --label shipping \ 'Which topics appear?' | jq -c '.detail.labels'Output
{"billing":0.9,"shipping":0.8}
tag keeps each label whose chance reaches the bar, 0.5 by default. Both 0.9 and 0.8 reach it. JSON output lists every field.
Move the bar
Section titled “Move the bar”Move the bar
Raise the bar to 0.85 and only billing is kept, because shipping has 0.8.
echo 'I was charged twice and my parcel is late again.' | thinkthen tag --threshold 0.85 \ --label billing --label shipping \ 'Which topics appear?'Output
billing
Lower the bar to give more labels. Raise it to give only the clear ones.
Label every row of a CSV file
Section titled “Label every row of a CSV file”Label every row of a CSV file
id,texta1,Please refund my order.a2,Where is my parcel?a3,I was charged twice for one invoice.thinkthen tag --column text --into topics \ --label billing --label shipping \ --from csv 'Which topics appear?' < messages.csvOutput
id,text,topics
a1,Please refund my order.,billing
a2,Where is my parcel?,shipping
a3,I was charged twice for one invoice.,billing
--column names the column to read, and --into names the new answer column. When a row gets several labels, the cell holds them joined by ; . File types covers TSV, Excel and other files.
Options
Section titled “Options”Options
| Option | What 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 |
--threshold <THRESHOLD> | Required probability |
--label <LABEL> | Label; repeat in order |
--describe <LABEL=TEXT> | Description for a label; repeat |
--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 |
If tag 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: score places a text on a scale from 0 to 1.