Skip to content

filter

filter keeps original messages that answer yes, using one bar.

Terminal window
thinkthen filter \
'Does the customer request a refund?' messages.txt

Output

Please refund my order.
I was charged twice for one invoice.
messages.txt
Please refund my order.
Where is my parcel?
I was charged twice for one invoice.

filter means "give me the yeses". It prints your own messages, in order.

Terminal window
thinkthen filter 'Does the customer request a refund?' messages.txt |
while IFS= read -r refund_request; do
echo "refund queue: $refund_request"
done

filter takes one bar, so every message is a yes or a no and none is left out for being not sure. --threshold 0.7 moves the bar. --low and --high are refused with exit code 2 and a message that names thinkthen decide: when you want not sure, use decide over the same file, as in the section above.

If a message fails, you still get every kept message. filter names each failed message on standard error, with its position and id, and exits 6 after the last message.

Terminal window
status=0
thinkthen filter \
'Does the customer request a refund?' \
messages.txt > refunds.txt || status=$?
if [ "$status" -eq 6 ]; then
echo "try again later: some messages could not be judged"
fi

filter prints your messages and nothing else, so it has no --json. To get each failed message back with its error code, run thinkthen decide --json over the same file.

With --check, filter answers "did any message say yes", as grep -q does: 0 when one did, 1 when none did, 6 when a message failed.

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
--low <LOW>Low probability bar
--high <HIGH>High probability bar
--check [=<CHECK>]Return the verdict as an exit code
--yes-means <TEXT>Meaning of a true answer
--no-means <TEXT>Meaning of a false answer
--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