Skip to content

tag

tag asks a bounded question about text and returns an answered, not-sure or failed result.

Terminal window
printf '%s' 'I was charged twice and my parcel is late again.' |
thinkthen tag --label billing --label shipping \
'Which topics appear?'

Output

billing	shipping

Labels work as choices do. The answer is the list of labels that fit, and it can be empty.

Terminal window
topics=$(thinkthen tag 'Which topics appear?' \
--text 'I was charged twice and my parcel is late again.' \
--label billing --label shipping --json)
if jq -e '.answer | index("billing")' <<< "$topics" > /dev/null; then
echo "billing team"
fi
jq -r '.answer[]' <<< "$topics"

tag is never not sure. --threshold sets how likely a label must be to count. Without --json, tag prints the labels on one line with tabs between them, and an empty line when none fit.

Read the CSV file and save its answers

--column selects the CSV column to judge; --into names the answer column. Check the exit status before using the saved file.

messages.csv
message
I was charged twice and my parcel is late again.
Terminal window
thinkthen tag 'Which topics appear?' messages.csv \
--label billing --label shipping \
--column message --into topics
cat messages.thinkthen.csv

Output

messages.thinkthen.csv
message,topics
I was charged twice and my parcel is late again.,billing; shipping
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
--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

Shared options