Advanced

Ranking as a score with a reason

An order needs a number, and the number needs a reason. The reason is written, and a written reason is what makes an order arguable.

What you will see

refuse. A number with no claim cannot be argued with.

About 1 min of reading

Try It

Write the parts and the tie rule

1

Write three parts

printf 'matches 3\ndoc_length 120\nfresh 1\n' > /tmp/p.txt; cat /tmp/p.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Three lines. Each line is a claim about the document.
2

Break a tie

printf 'a 5\nb 5\n' | sort -k1,1 | head -1

Before you run it, say out loud what it will print. Then open the answer.

What it prints
a 5. The name broke the tie, which is the written second number.
3

Refuse a part with no claim

printf 'part=boost claim=none\n' | awk '{print ($2=="claim=none") ? "refuse" : "keep"}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
refuse. A number with no claim cannot be argued with.

Data Flow

A document to a score with a reason
1 Each part is computed with a claim
↓
2 The parts are summed
↓
3 A tie is broken by a written second number
↓
4 The score is kept in the answer
Why this works
Why the parts are separate

A part that is separate is a part that can be turned off. Turning off is a decision, and a decision is a line in a file.

The one part that must be refused

A part with no claim behind it. A number with no claim is a number that cannot be argued with.

Examples

The score is a sum of parts

Each part is a claim about the document. A sum is a claim, and a claim is what a test can check.

A tie is broken by a rule

Two documents with one score need a second number. The second number is written, and written is the decision.

The score is kept in the answer

The answer shows the number. A number in the answer is a number a reader can argue with.

← Answering a query
Previous Lesson
Answering a query
Next Lesson
Word weight from the library
Word weight from the library →