Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs/toolkit/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Work | W######## | `openpecha.core.metadata.WorkMetadata` |
Initial | I######## | `openpecha.core.metadata.InitialPechaMetadata` |
Diplomatic | D######## | `openpecha.core.metadata.DiplomaticPechaMetadata` |
Open | O######## | `openpecha.core.metadata.OpenPechaMetadata` |
Alignment | A######## | `` |
Collection | C######## | `` |
Alignment | A######## | `openpecha.core.metadata.AlignmentMetadata` |
Collection | C######## | `openpecha.core.metadata.CollectionMetadata` |

here is an example to create metadata for *Initial Pecha* type

Expand Down
43 changes: 41 additions & 2 deletions openpecha/core/metadata.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import datetime
from enum import Enum
from typing import Dict, Optional, Union
from typing import Dict, Optional, Union,List

from pydantic import AnyHttpUrl, BaseModel, Extra, validator

from . import ids

import re

class InitialCreationType(Enum):
ocr = "ocr"
Expand Down Expand Up @@ -115,3 +115,42 @@ class DiplomaticPechaMetadata(PechaMetadata):
@validator("id", pre=True, always=True)
def set_id(cls, v):
return v or ids.get_diplomatic_id()

class AlignmentMetadata(BaseModel):
id:str
title:str
type: str
pechas: List[str]
alignment_to_base:Dict[str,str]
source_metadata: Optional[Dict] = None

class InstanceMetadata(BaseModel):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you document a little bit what an instance, an alignment, a work and a collection are? My intuition is that instances should not have authors but should instead have works, but since it's all a bit unclear I'm not sure

id: str
title: List[str]
colophon: str
authors: List[str]
bdrc_id: str
location_info: dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does that mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above attributes of Instance metadata are extracted from the using this api pasing the instance id to it.The code is over here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but that's not really how it should work: the design of the metadata in OpenPecha shouldn't be driven by some query I made quickly a few months ago, there should be some proper design effort to create good OpenPecha metadata, document it and then build a query to get this data from BDRC

diplomatic_id:Optional[List[str]]
alignmnet_ids:Optional[List[str]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be alignment

collection_ids:Optional[List[str]]

@validator("diplomatic_id")
def validate_diplonatic_id(cls,value):
if not re.match(r"I.*",value):
raise ValueError("Pecha Id is not Diplomatic")


class WorkMetadata(BaseModel):
id: str
title: str
alternative_title: Optional[str]
language: str
bdrc_work_id: str
authors: List[str]
best_instance:Optional[InstanceMetadata]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't that be best_instance_id: str instead?

instances: Optional[List[InstanceMetadata]]


class CollectionMetadata:
pass