# Inspection rubric: Arabic document OCR, layout and field extraction (v0.1)

Use this with the six pages and 22 field items in this kit, or with your own pages in the same format.

## 1. Protocol

1. **Write the reading policy first.** Decide before you run anything: whether Eastern Arabic digits (٠١٢٣٤٥٦٧٨٩) and Western digits (0123456789) count as the same in transcription (the default below says no for transcription and yes for normalized values), whether the Arabic decimal separator ٫ and thousands separator ٬ must be kept, which letter forms you normalize, and which date format normalized dates use (the kit uses ISO `YYYY-MM-DD`, with Hijri dates kept in the Hijri calendar).
2. **Run three tasks separately.**
   - *Reading:* ask for all text on the page, one line per region, in reading order. Compare with `transcription` and `reading_order` in `annotations.jsonl`.
   - *Layout:* for D01, D04 and D06, ask for the table as rows and columns. Compare with each cell's `table` row and column (columns are counted from the right, because the tables run right to left).
   - *Fields:* give the page and one item from `fields.jsonl` at a time. Ask for the value as printed, a normalized value, and, if the model supports it, a box for where the value is.
3. **Ask for a validation check on D01, D02 and D06.** Ask whether the totals add up. Compare with `validation` in `annotations.jsonl`: D06 is built not to add up.
4. **Use the same prompt and settings for every model.** Fix the temperature or seed, keep the first output and store it raw.
5. **Mark each output** pass or fail, with one or more error codes from section 3 for each failure.
6. **Report by error code, not one score** (section 5). Keep the failing outputs and rerun the same items after a fix.

## 2. Default normalization policy

- **Transcription keeps the page.** Digits stay in the script printed on the page, separators stay as printed (٫ ٬ . ,), and nothing is expanded or translated. Writing ٣٨٫٧٥ as 38.75 in a transcription is OCR_DIGIT.
- **Normalized values are for comparison.** In `value_normalized`, Eastern and Western digits are equal, amounts use a full stop as the decimal mark with two decimals, dates are ISO, and a ticked checkbox is its English option name.
- **Both values are kept.** A field output that has only a normalized value, with no record of what the page shows, is FLD_NORM.
- **Letter forms.** For comparing names, alef forms أ إ آ may be mapped to ا, ى to ي and ة to ه, and tatweel and diacritics removed. A dot error is still a failure: فلان read as قلان is OCR_DOT.
- **Empty is a value.** For an empty field the expected output is `null`. Any text is FLD_HALLUC.
- **Calendars are not converted silently.** A Hijri date on the page is reported as a Hijri date. Converting it to Gregorian, unless your task asks for that, is DATE_CAL; a conversion that is asked for is checked against the calendar your policy names (the kit's Hijri dates follow Umm al-Qura).

## 3. Error codes

### Reading

| Code | Failure |
|---|---|
| OCR_DOT | A letter read as another with the same shape and different dots (ب ت ث ن ي, ج ح خ, س ش, ص ض, ط ظ, ع غ, ف ق) |
| OCR_DIGIT | A digit misread, or digits converted between Eastern Arabic and Western in a transcription |
| OCR_SEP | A decimal or thousands separator lost or changed, so the amount changes (٣٨٫٧٥ read as ٣٨٧٥) |
| OCR_BIDI | A line that mixes Arabic with Latin text, digits or slashes stored in display order instead of logical order (INV-0042 or ٤٥/ب/١٤٤٨ reversed or split) |
| OCR_ORDER | Blocks read in the wrong order: the English header before the Arabic one, the totals labels detached from their values, a two-column header read across |
| OCR_DROP | A text region missed: a specimen notice, a footer, a header line |
| OCR_STRUCK | Struck-through text reported as the current value, or the correction beside it missed |

### Layout and fields

| Code | Failure |
|---|---|
| LAY_TABLE | Table columns reversed, cells merged or split, or the header row mixed into the data |
| LAY_ROW | A value taken from the wrong row of a table, receipt or totals block |
| FLD_WRONG | A wrong field value with no other explanation |
| FLD_NORM | Only a normalized value returned, with no value as printed; or a normalized value that changes the meaning |
| FLD_HALLUC | A value invented for an empty field (F10, F17) |
| FLD_EVIDENCE | No evidence box, or a box that does not overlap the listed evidence regions with an intersection over union of 0.5 or more |
| FLD_CHECKBOX | A checkbox read wrongly, or the tick attached to the neighbouring option |
| DATE_CAL | Hijri and Gregorian dates confused, a date converted without being asked, or day and month swapped (16/11/2026 is 16 November) |
| VAL_MISS | A total that does not add up accepted without a flag (D06), or a consistent total flagged |

### Record checks

| Code | Failure |
|---|---|
| REC_SOURCE | A page record with no source type (genuine, de-identified or synthetic) |
| REC_SPLIT | Pages from one issuer or template on both sides of a train/test split |

## 4. Evidence and empty fields

- Each field item lists `evidence_regions`, the value region first. A box passes if its intersection over union (IoU) with at least one listed region is 0.5 or more. Region boxes cover the rendered line or cell text, so a box around a whole table row can score lower; check failures by eye before you report them.
- Two field items have no value on the page: F10 (mobile number) and F17 (receiver name). Their evidence is the empty line and its label.
- F12 tests a correction: ٣ is struck through and ٢ is written beside it. The current value is 2.
- F21 tests extraction and validation together: extract the printed total as printed (470.00) and report, separately, that it does not equal 400.00 + 60.00.

## 5. Reporting

Report counts per error code and per page, with the model or OCR engine name, version, prompt and settings. Do not turn 22 items into a percentage: the kit shows which failure types occur, not how often they occur on your documents. Clean rendered pages are easier than scans and phone photos: D06 adds blur and low contrast, but no rendered page stands in for real capture.

## 6. Record checks to agree with a supplier

Before a custom document collection or annotation project, agree that every page record states, as in `schema.json`:

- **Source type:** genuine, de-identified or synthetic, per page, with how de-identification changed the page (masked boxes, or replacement values in the same format) and which fields it touched.
- **Issuer group and template:** which issuer and which template each page comes from, so template diversity is reported separately from page count.
- **Split group:** the unit that must stay on one side of a split. In this kit D01, D05 and D06 share the issuer group `example-trading`, and D01 and D06 share template `T-INV-A`, so all three belong in the same split.
- **Capture:** flatbed scan, phone photo, fax or digital render, and the degradations present.
- **Two values per field:** the value as printed and the normalized value, with the evidence region for each.
- **Rights, each separately:** model training, evaluation, redistribution and public display, each `granted`, `not_granted` or `not_stated`, with a reference to the permission record. A right that is not written down is `not_stated`, never assumed.
