* One row, with what a reviewer needs appended to it. * * Confidence stays a number on the row as well as a label: the renderer puts it * in its own element so it can be found, checked and styled as the qualified * claim it is, and a consumer that wants to threshold on it does not have to * par
(ir: SemanticIR, row: TwinRow, state: KnowledgeState)
| 665 | * parse a sentence. |
| 666 | */ |
| 667 | function densifyRow(ir: SemanticIR, row: TwinRow, state: KnowledgeState): TwinRow { |
| 668 | // A row with no fact path makes no claim about the code, so it has no |
| 669 | // certainty to report and no citations to count. |
| 670 | if (row.factPath.length === 0) { |
| 671 | return row; |
| 672 | } |
| 673 | const citations = evidenceFor(ir, row.factPath); |
| 674 | const call = callFor(ir, row.factPath); |
| 675 | const confidence = call?.confidence ?? citations[0]?.confidence; |
| 676 | const strategy = call?.strategy ?? citations[0]?.strategy; |
| 677 | const certainty = certaintyOf(confidence, state); |
| 678 | const extras: string[] = []; |
| 679 | if (strategy !== undefined) { |
| 680 | extras.push(strategyLabel(strategy)); |
| 681 | } |
| 682 | if (citations.length > 0) { |
| 683 | extras.push(citationCount(citations.length)); |
| 684 | } |
| 685 | return { |
| 686 | ...row, |
| 687 | confidence, |
| 688 | confidenceLabel: certainty.label, |
| 689 | confidenceNote: certainty.note, |
| 690 | extras: extras.length > 0 ? extras : undefined |
| 691 | }; |
| 692 | } |
| 693 | |
| 694 | // --------------------------------------------------------------------------- |
| 695 | // level 1, junior: the order, the connective between the steps, and the words |
no test coverage detected