Skip to content

Annotations

All the annotations in OPF are just span of start and end character the base layer and some attributes of the particular annotation. The most simplest form of annotation is just having the a span. Here is the list of annotation currently supported by OpenPecha.

Annotations in OpenPecha are broadly categorized into Physical and Semantic annotations.

Semantic Annotations

Any annotations from the Verbal text

Citation

Citation

JSON Schema
{
  "title": "Citation",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Citation, Span

citation = Citation(span=Span(start=10, end=30))

assert citation.span.start == 10

Correction

Correction

JSON Schema
{
  "title": "Correction",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Correction, Span

correction = Correction(span=Span(start=10, end=30))

assert correction.span.start == 10

ErrorCandidate

ErrorCandidate

JSON Schema
{
  "title": "ErrorCandidate",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import ErrorCandidate, Span

error_candidate = ErrorCandidate(span=Span(start=10, end=30))

assert error_candidate.span.start == 10

Pedurma

Pedurma

JSON Schema:
{
  "title": "Pedurma",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example:
from openpecha.core.annotations import Pedurma, Span

pedurma = Pedurma(span=Span(start=10, end=30))

assert pedurma.span.start == 10

Sabche

Sabche

JSON Schema
{
  "title": "Sabche",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Sabche, Span

sabche = Sabche(span=Span(start=10, end=30))

assert sabche.span.start == 10

Tsawa

Tsawa

JSON Schema
{
  "title": "Tsawa",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Span, Tsawa

tsawa = Tsawa(span=Span(start=10, end=30))

assert tsawa.span.start == 10

Yigchung

Yigchung

JSON Schema
{
  "title": "Yigchung",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Span, Yigchung

yigchung = Yigchung(span=Span(start=10, end=30))

assert yigchung.span.start == 10

Archaic

Archaic

JSON Schema
{
  "title": "Archaic",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Archaic, Span

archaic = Archaic(span=Span(start=10, end=30))

assert archaic.span.start == 10

Durchen

Durchen

JSON Schema
{
  "title": "Durchen",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    },
    "default": {
      "title": "Default",
      "description": "text_name of the default option",
      "type": "string"
    },
    "options": {
      "title": "Options",
      "description": "all other spell options in dict of {text_name, option}",
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    }
  },
  "required": [
    "span",
    "default",
    "options"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Durchen, Span

base = "སེམས་ཅན་རྣམས་ལ་སླུ་བ་ཡི།"
durchen = Durchen(
    span=Span(start=15, end=18),
    default="སྡེ།",
    options={"ཅོ།": "སླུ་", "པེ།": "བསླུ།", "སྣར།": "བསླུ།"},
)

assert base[durchen.span.start : durchen.span.end + 1] == "སླུ་"

Footnote

Footnote

JSON Schema
{
  "title": "Footnote",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Footnote, Span

footnote = Footnote(span=Span(start=10, end=30))

assert footnote.span.start == 10

Segment

Segment of an alignment

JSON Schema
{
  "title": "Segment",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Segment, Span

segment = Segment(span=Span(start=10, end=30))

assert segment.span.start == 10

Physical Annotations

BookTitle

Title of the book

SubTitle

Sub title of the book

Edition

It can be Edition number/name. Previously called BookNumber.

Author

author of the book

Chapter

Chapter title

Text

Represents text and used in Index layer.

SubText

Represents Sub text and used in Index layer.

Pagination

Represents the single page of a text.

JSON Schema
{
  "title": "Pagination",
  "type": "object",
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "span": {
      "$ref": "#/definitions/Span"
    },
    "metadata": {
      "title": "Metadata",
      "default": {},
      "type": "object"
    },
    "page_info": {
      "title": "Page Info",
      "description": "page payload",
      "type": "string"
    },
    "imgnum": {
      "title": "Imgnum",
      "description": "image sequence number",
      "type": "integer"
    },
    "order": {
      "title": "Order",
      "description": "order of the page",
      "type": "integer"
    },
    "reference": {
      "title": "Reference",
      "description": "can be url or just string indentifier of source page",
      "type": "string"
    }
  },
  "required": [
    "span"
  ],
  "additionalProperties": false,
  "definitions": {
    "Span": {
      "title": "Span",
      "type": "object",
      "properties": {
        "start": {
          "title": "Start",
          "minimum": 0,
          "type": "integer"
        },
        "end": {
          "title": "End",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    }
  }
}
Python example
from openpecha.core.annotations import Pagination, Span

pagination = Pagination(span=Span(start=10, end=30))

assert pagination.span.start == 10