{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.bayanatlabs.com/research/arabic-document-ocr-kit/v0.1/schema.json",
  "title": "Annotated Arabic document page record (Bayanat Labs Arabic Document OCR Inspection Kit v0.1)",
  "description": "One record per page image: source type, issuer and template, split group, capture, text and non-text regions with reading order and table cells, fields with the value as printed and the normalized value plus evidence regions, validation checks, and a separate field for each right.",
  "type": "object",
  "required": [
    "page_id",
    "file",
    "width",
    "height",
    "doc_type",
    "source",
    "de_identification",
    "issuer_group",
    "template_id",
    "split_group",
    "capture",
    "regions",
    "fields",
    "rights"
  ],
  "properties": {
    "page_id": {
      "type": "string"
    },
    "file": {
      "type": "string"
    },
    "width": {
      "type": "integer",
      "minimum": 1
    },
    "height": {
      "type": "integer",
      "minimum": 1
    },
    "doc_type": {
      "type": "string",
      "examples": [
        "invoice",
        "receipt",
        "form",
        "delivery_note",
        "letter",
        "contract",
        "statement"
      ]
    },
    "description_en": {
      "type": "string"
    },
    "languages": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "source": {
      "type": "object",
      "required": [
        "type",
        "generated"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "genuine",
            "de_identified",
            "synthetic"
          ],
          "description": "Per page. Never count synthetic or de-identified pages as genuine."
        },
        "method": {
          "type": "string"
        },
        "generated": {
          "type": "boolean"
        }
      }
    },
    "de_identification": {
      "type": "object",
      "required": [
        "applied"
      ],
      "properties": {
        "applied": {
          "type": "boolean"
        },
        "method": {
          "type": "string",
          "enum": [
            "masked_boxes",
            "format_preserving_replacement",
            "not_applicable",
            "other"
          ]
        },
        "fields_affected": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "note": {
          "type": "string"
        }
      }
    },
    "issuer_group": {
      "type": "string",
      "description": "The issuer or source organization; template diversity is reported per issuer and template, separately from page count."
    },
    "template_id": {
      "type": "string"
    },
    "split_group": {
      "type": "string",
      "description": "All pages with the same split_group stay on one side of a train/test split."
    },
    "capture": {
      "type": "object",
      "required": [
        "method"
      ],
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "flatbed_scan",
            "phone_photo",
            "fax",
            "digital_render",
            "born_digital_pdf",
            "other"
          ]
        },
        "degradation": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "regions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "region_id",
          "kind",
          "bbox_xywh"
        ],
        "properties": {
          "region_id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "text",
              "checkbox",
              "blank_field",
              "stamp",
              "signature",
              "image"
            ]
          },
          "bbox_xywh": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "minItems": 4,
            "maxItems": 4,
            "description": "[x, y, width, height] in pixels from the top-left corner."
          },
          "transcription": {
            "type": "string",
            "description": "The text as printed, in logical (reading) order, digits and separators unchanged."
          },
          "script": {
            "type": "string",
            "enum": [
              "arabic",
              "latin",
              "mixed",
              "numeric",
              "symbol"
            ]
          },
          "digits": {
            "type": "string",
            "enum": [
              "none",
              "eastern",
              "western",
              "mixed"
            ]
          },
          "reading_order": {
            "type": "integer",
            "minimum": 1
          },
          "role": {
            "type": "string"
          },
          "legibility": {
            "type": "string",
            "enum": [
              "full",
              "degraded",
              "partly_occluded",
              "illegible"
            ]
          },
          "table": {
            "type": "object",
            "required": [
              "table_id",
              "row",
              "col"
            ],
            "properties": {
              "table_id": {
                "type": "string"
              },
              "row": {
                "type": "integer",
                "minimum": 0
              },
              "col": {
                "type": "integer",
                "minimum": 0
              },
              "col_order": {
                "type": "string",
                "enum": [
                  "right_to_left",
                  "left_to_right"
                ]
              }
            }
          },
          "struck_through": {
            "type": "boolean"
          },
          "superseded_by": {
            "type": "string"
          },
          "entry": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "checked",
              "unchecked"
            ]
          },
          "label_region": {
            "type": "string"
          },
          "occluded_by": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      }
    },
    "fields": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "field_id",
          "key",
          "value_as_printed",
          "value_normalized",
          "empty",
          "evidence_regions"
        ],
        "properties": {
          "field_id": {
            "type": "string"
          },
          "key": {
            "type": "string"
          },
          "value_as_printed": {
            "type": [
              "string",
              "null"
            ]
          },
          "value_normalized": {
            "type": [
              "string",
              "null"
            ]
          },
          "empty": {
            "type": "boolean"
          },
          "evidence_regions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          }
        }
      }
    },
    "validation": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "check_id",
          "rule",
          "status"
        ],
        "properties": {
          "check_id": {
            "type": "string"
          },
          "rule": {
            "type": "string"
          },
          "computed": {
            "type": "string"
          },
          "printed_total": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "consistent",
              "inconsistent",
              "not_checked"
            ]
          },
          "evidence_regions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "rights": {
      "type": "object",
      "required": [
        "model_training",
        "evaluation",
        "redistribution",
        "public_display",
        "permission_record"
      ],
      "properties": {
        "model_training": {
          "type": "string",
          "enum": [
            "granted",
            "not_granted",
            "not_stated"
          ]
        },
        "evaluation": {
          "type": "string",
          "enum": [
            "granted",
            "not_granted",
            "not_stated"
          ]
        },
        "redistribution": {
          "type": "string",
          "enum": [
            "granted",
            "not_granted",
            "not_stated"
          ]
        },
        "public_display": {
          "type": "string",
          "enum": [
            "granted",
            "not_granted",
            "not_stated"
          ]
        },
        "permission_record": {
          "type": "string"
        }
      }
    },
    "illustrative": {
      "type": "boolean"
    }
  }
}