Define the local evaluation task
A synthetic form field contains observed text spans with a struck Boolean and supplied text string. An explicit empty string is a known blank transcription, while absent/nontext span content is invalid. Under this local transcription rule, struck spans are historical values and exactly one unstruck span is the current value. Zero or multiple current candidates require review. The marks are supplied observations; the evaluator does not detect handwriting.
- Separate struck and unstruck spans
- Count current candidates
- Accept one or retain review candidates
Multiple or absent current spans require the original field to be reviewed.
Use the filled cases
| Case | Supplied input | Expected structured output | Decision and reason |
|---|---|---|---|
| One visible replacement | {"spans":[{"text":"12","struck":true},{"text":"14","struck":false}]} | {"old":["12"],"current":"14","candidates":["14"],"status":"accepted"} | Fourteen is current; twelve remains retained as the visible prior text. |
| Two unstruck candidates | {"spans":[{"text":"14","struck":false},{"text":"16","struck":false}]} | {"old":[],"current":null,"candidates":["14","16"],"status":"review"} | The rule supplies no last-write or nearest-text tie breaker. |
| Strike label is text | {"spans":[{"text":"14","struck":"false"}]} | {"error":"observation-label"} | The text false is not a Boolean observation and cannot be treated as a clear mark. |
| Observed span text absent | {"spans":[{"struck":false}]} | {"error":"observation-text"} | A clear unstruck flag alone cannot establish the missing current text. |
| Explicit observed blank | {"spans":[{"text":"","struck":false}]} | {"old":[],"current":"","candidates":[""],"status":"accepted"} | The empty text is an observed blank value, not an absent span-text channel. |
| All values struck | {"spans":[{"text":"12","struck":true}]} | {"old":["12"],"current":null,"candidates":[],"status":"review"} | A visible old value cannot fill a missing current value. |
Work the all-struck case. Which output is required, and why?
Show the worked answer
{"old":["12"],"current":null,"candidates":[],"status":"review"} — A visible old value cannot fill a missing current value.
Run the self-contained evaluator
import assert from 'node:assert/strict';
function evaluate(x){
if(x.spans.some(s=>typeof s.text!=='string'))return {error:'observation-text'};
if(x.spans.some(s=>typeof s.struck!=='boolean'))return {error:'observation-label'};
const old=x.spans.filter(s=>s.struck).map(s=>s.text),current=x.spans.filter(s=>!s.struck).map(s=>s.text);
return {old,current:current.length===1?current[0]:null,candidates:current,status:current.length===1?'accepted':'review'};
}
const cases = [
{
"id": "one-replacement",
"input": {
"spans": [
{
"text": "12",
"struck": true
},
{
"text": "14",
"struck": false
}
]
},
"expected": {
"old": [
"12"
],
"current": "14",
"candidates": [
"14"
],
"status": "accepted"
}
},
{
"id": "two-current-spans",
"input": {
"spans": [
{
"text": "14",
"struck": false
},
{
"text": "16",
"struck": false
}
]
},
"expected": {
"old": [],
"current": null,
"candidates": [
"14",
"16"
],
"status": "review"
}
},
{
"id": "string-strike-label",
"input": {
"spans": [
{
"text": "14",
"struck": "false"
}
]
},
"expected": {
"error": "observation-label"
}
},
{
"id": "span-text-absent",
"input": {
"spans": [
{
"struck": false
}
]
},
"expected": {
"error": "observation-text"
}
},
{
"id": "explicit-blank-transcription",
"input": {
"spans": [
{
"text": "",
"struck": false
}
]
},
"expected": {
"old": [],
"current": "",
"candidates": [
""
],
"status": "accepted"
}
},
{
"id": "all-struck",
"input": {
"spans": [
{
"text": "12",
"struck": true
}
]
},
"expected": {
"old": [
"12"
],
"current": null,
"candidates": [],
"status": "review"
}
}
];
for (const c of cases) assert.deepEqual(evaluate(c.input), c.expected, c.id);
console.log(JSON.stringify({checked:cases.length,caseIds:cases.map(c=>c.id)}));
Retain old and current transcription separately. This local edit-mark convention must be supplied for a new document; a visible strike is not a universal authorisation rule.