Skip to content

Pecha Metadata

Create Metadata for a Pecha

Since, OpenPecha as has three types of pecha, we have metadata classes to create metadata for each type of pecha. Here is the list of pecha types with it's associated metadata class.

Pecha Type ID format Metadata Class
Initial I######## openpecha.core.metadata.InitialPechaMetadata
Diplomatic D######## openpecha.core.metadata.DiplomaticPechaMetadata
Open O######## openpecha.core.metadata.OpenPechaMetadata
Alignment A######## ``
Collection C######## ``

here is an example to create metadata for Initial Pecha type

from openpecha.core.metadata import InitialCreationType, InitialPechaMetadata

metadata = InitialPechaMetadata(
    source="https://library.bdrc.io",
    source_file="https://library.bdrc.io/text.json",
    initial_creation_type=InitialCreationType.ocr,
    parser="https://github.com/OpenPecha-dev/openpecha-toolkit/pgoogle_orc.py",
    source_metadata={
        "id": "bdr:W1PD90121",
        "title": "མའོ་རྫོང་གི་ས་ཆའི་མིང་བཏུས།",
        "author": "author name",
    },
)


assert metadata.id.startswith("I")

Attention

Only the initial_creation_type attribute is required, rest of the attributes are optional.

Attention

No need to assign pecha id when creating metadata, the metadata class will automatically create id with correct id prefix for a particular pecha type.

Examples

all developers should follow schema for source_metadata and base as in given examples

Initial Pecha Metadata

id: I7E1A43F2
source: https://library.bdrc.io
source_file: null
initial_creation_type: ocr
imported: '2020-03-28T12:12:38+00:00'
last_modified: '2022-06-08T11:28:52.590761+00:00'
parser: https://github.com/OpenPecha-dev/openpecha-toolkit/blob/231bba39dd1ba393320de82d4d08a604aabe80fc/openpecha/formatters/google_orc.py
ocr_word_median_confidence_index: 0.9
source_metadata:
    id: bdr:W3CN4314
    title: ཚད་མ་རིགས་པའི་གཏེར་གྱི་རྩ་བ།
    author: ''
    access: http://purl.bdrc.io/admindata/AccessOpen
    restrictedInChina: false
base:
    529C:
      source_metadata:
          image_group_id: I3CN8548
          title: ''
          total_pages: 62
      order: 1
      base_file: 529C.txt
      ocr_word_median_confidence_index: 0.9

here is an example to add copyright and license in pecha's metadata

from openpecha.core.metadata import (
    Copyright,
    CopyrightStatus,
    InitialCreationType,
    LicenseType,
    PechaMetadata,
)

copyright = Copyright(
    status=CopyrightStatus.COPYRIGHTED,
    notice="Copyright 2022 OpenPecha",
    info_url="https://dev.openpecha.org/terms-and-conditions",
)

metadata = PechaMetadata(
    initial_creation_type=InitialCreationType.input,
    copyright=copyright,
    license=LicenseType.CC_BY_NC_SA,
)

print(metadata)

OpenPecha provides three Copyright Status:

  • CopyrightStatus.UNKNOWN, use if the Copyright of the pecha is unknown.
  • CopyrightStatus.COPYRIGHTED, use if the pecha source is Copyright restricted.
  • CopyRightStatus.PUBLIC_DOMAIN, use if the pecha source is in Public Domain.

Licenses

OpenPecha relies on Creative Common Licenses for licensing any pecha on OpenPecha Repository,

We can access Creative Common Licenses through LicenseType enum.