diff --git a/src/openpecha/alignment/serializers/simple_text_translation.py b/src/openpecha/alignment/serializers/translation.py similarity index 84% rename from src/openpecha/alignment/serializers/simple_text_translation.py rename to src/openpecha/alignment/serializers/translation.py index ad5b36d..9aa1ddc 100644 --- a/src/openpecha/alignment/serializers/simple_text_translation.py +++ b/src/openpecha/alignment/serializers/translation.py @@ -10,7 +10,7 @@ from openpecha.utils import get_text_direction_with_lang, write_json -class SimpleTextTranslationSerializer(BaseAlignmentSerializer): +class TextTranslationSerializer(BaseAlignmentSerializer): def __init__(self): self.root_json: Dict[str, List] = { "categories": [], @@ -108,7 +108,7 @@ def set_root_content(self): segments = self.get_texts_from_layer(segment_layer) self.root_json["books"][0]["content"] = [segments] - def set_translation_content(self): + def set_translation_content(self, is_pecha_display: bool): """ Processes: 1. Get the first txt file from root and translation opf @@ -131,13 +131,19 @@ def set_translation_content(self): ann_data = {} for data in ann: ann_data[str(data.key().id())] = data.value().get() - if "alignment_mapping" in ann_data: - for map in ann_data["alignment_mapping"]: - root_map = map[0] - if root_map in segments: - segments[root_map].append(str(ann)) - else: - segments[root_map] = [str(ann)] + + if is_pecha_display: + if "alignment_mapping" in ann_data: + for map in ann_data["alignment_mapping"]: + root_map = map[0] + if root_map in segments: + segments[root_map].append(str(ann)) + else: + segments[root_map] = [str(ann)] + else: + if "root_idx_mapping" in ann_data: + root_map = int(ann_data["root_idx_mapping"]) + segments[root_map] = [str(ann)] max_root_idx = max(segments.keys()) translation_segments = [] @@ -149,7 +155,7 @@ def set_translation_content(self): self.translation_json["books"][0]["content"] = [translation_segments] - def get_pecha_display_aligment(self): + def get_root_and_translation_layer(self): """ Get the root layer and translation layer to serialize the layer(STAM) to JSON 1.First it checks if the 'pecha_display_segment_alignments' contains in the metadata (from translation opf) @@ -157,7 +163,7 @@ def get_pecha_display_aligment(self): """ assert isinstance( self.translation_opf_path, Path - ), "Translation opf path is not set for 'get_pecha_display_aligment'" + ), "Translation opf path is not set for 'get_root_and_translation_layer'" pecha = Pecha.from_path(self.translation_opf_path) if "pecha_display_segment_alignments" in pecha.metadata.source_metadata: pecha_display_alignment = pecha.metadata.source_metadata[ @@ -171,9 +177,18 @@ def get_pecha_display_aligment(self): self.translation_opf_path, Path ), "Translation opf path is not set" - root_layer_path = next(self.root_opf_path.rglob("*.json")).as_posix() + root_jsons = list(self.root_opf_path.rglob("*.json")) + root_layer_path = next( + root_json + for root_json in root_jsons + if root_json.name != "metadata.json" + ).as_posix() + + translation_jsons = list(self.translation_opf_path.rglob("*.json")) translation_layer_path = next( - self.translation_opf_path.rglob("*.json") + translation_json + for translation_json in translation_jsons + if translation_json.name != "metadata.json" ).as_posix() self.root_basename = root_layer_path.split("/")[-2] @@ -196,6 +211,7 @@ def serialize( root_opf_path: Path, translation_opf_path: Path, output_path: Path = SERIALIZED_ALIGNMENT_JSON_PATH, + is_pecha_display: bool = True, ) -> Path: self.root_opf_path = root_opf_path @@ -210,11 +226,11 @@ def serialize( self.set_pecha_category(pecha_title) # Get the root and translation layer to serialize the layer(STAM) to JSON - self.get_pecha_display_aligment() + self.get_root_and_translation_layer() # Set the content for source and target and set it to JSON self.set_root_content() - self.set_translation_content() + self.set_translation_content(is_pecha_display) # Write the JSON to the output path json_output_path = output_path / "alignment.json" diff --git a/tests/alignment/serializers/translation/data/bo/IFA46BBC2/base/4665.txt b/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/base/3635.txt similarity index 100% rename from tests/alignment/serializers/translation/data/bo/IFA46BBC2/base/4665.txt rename to tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/base/3635.txt diff --git a/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/layers/3635/Tibetan_Segment-039B.json b/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/layers/3635/Tibetan_Segment-039B.json new file mode 100644 index 0000000..6d6e523 --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/layers/3635/Tibetan_Segment-039B.json @@ -0,0 +1,1200 @@ +{ + "@type": "AnnotationStore", + "@id": "IE60BBDE9", + "resources": [ + { + "@type": "TextResource", + "@id": "3635", + "@include": "../../base/3635.txt" + } + ], + "annotationsets": [ + { + "@type": "AnnotationDataSet", + "@id": "Translation", + "keys": [ + { + "@type": "DataKey", + "@id": "root_idx_mapping" + }, + { + "@type": "DataKey", + "@id": "Translation_Segment" + } + ], + "data": [ + { + "@type": "AnnotationData", + "@id": "ACEEC93C", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "1" + } + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "key": "Translation_Segment", + "value": { + "@type": "String", + "value": "Tibetan_Segment" + } + }, + { + "@type": "AnnotationData", + "@id": "D9953B50", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "2" + } + }, + { + "@type": "AnnotationData", + "@id": "682E41D7", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "3" + } + }, + { + "@type": "AnnotationData", + "@id": "8C81BE18", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "4" + } + }, + { + "@type": "AnnotationData", + "@id": "8F99000B", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "5" + } + }, + { + "@type": "AnnotationData", + "@id": "84E09136", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "6" + } + }, + { + "@type": "AnnotationData", + "@id": "AD8F3F84", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "7" + } + }, + { + "@type": "AnnotationData", + "@id": "2D2681AE", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "8" + } + }, + { + "@type": "AnnotationData", + "@id": "894DFAC2", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "9" + } + }, + { + "@type": "AnnotationData", + "@id": "C4491101", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "10" + } + }, + { + "@type": "AnnotationData", + "@id": "2EC81518", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "11" + } + }, + { + "@type": "AnnotationData", + "@id": "4588EA06", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "12" + } + }, + { + "@type": "AnnotationData", + "@id": "3A71B6FA", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "13" + } + }, + { + "@type": "AnnotationData", + "@id": "077242BB", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "14" + } + }, + { + "@type": "AnnotationData", + "@id": "E4EB4442", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "15" + } + }, + { + "@type": "AnnotationData", + "@id": "8D026220", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "16" + } + }, + { + "@type": "AnnotationData", + "@id": "97C9A79E", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "17" + } + }, + { + "@type": "AnnotationData", + "@id": "8776EE10", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "18" + } + }, + { + "@type": "AnnotationData", + "@id": "584A5005", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "19" + } + }, + { + "@type": "AnnotationData", + "@id": "D815BE86", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "20" + } + }, + { + "@type": "AnnotationData", + "@id": "594BDFF4", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "21" + } + }, + { + "@type": "AnnotationData", + "@id": "8140851B", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "22" + } + }, + { + "@type": "AnnotationData", + "@id": "9844AC67", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "23" + } + }, + { + "@type": "AnnotationData", + "@id": "DAACC416", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "24" + } + }, + { + "@type": "AnnotationData", + "@id": "B033EA0C", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "25" + } + }, + { + "@type": "AnnotationData", + "@id": "C96CDCCC", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "26" + } + }, + { + "@type": "AnnotationData", + "@id": "19482BE8", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "27" + } + }, + { + "@type": "AnnotationData", + "@id": "34418988", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "28" + } + }, + { + "@type": "AnnotationData", + "@id": "921B3D5E", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "29" + } + } + ] + } + ], + "annotations": [ + { + "@type": "Annotation", + "@id": "8D11468B", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 0 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 68 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "ACEEC93C", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "B562E94E", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 69 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 158 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "D9953B50", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "A4089084", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 159 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 210 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "682E41D7", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "E58C0CAD", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 211 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 244 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "8C81BE18", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "CE31AD11", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 245 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 469 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "8F99000B", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "52D2BE87", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 470 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 623 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "84E09136", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "10E23027", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 624 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 735 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "AD8F3F84", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "4D84D935", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 736 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 895 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "2D2681AE", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "6D213C7C", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 896 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 957 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "894DFAC2", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "2AE72AAD", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 958 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1047 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "C4491101", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "24AD5670", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1048 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1120 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "2EC81518", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "131E022B", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1121 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1276 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "4588EA06", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "B438449F", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1277 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1314 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "3A71B6FA", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "FC23BBAF", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1315 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1607 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "077242BB", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "42D374B4", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1608 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1639 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "E4EB4442", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "87C7DAEF", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1640 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1715 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "8D026220", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "AE39A951", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1716 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1738 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "97C9A79E", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "959D4774", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1739 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1770 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "8776EE10", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "C541A6CB", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1771 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1793 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "584A5005", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "6ADEFFC1", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1794 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1860 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "D815BE86", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "89BBC999", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1861 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1888 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "594BDFF4", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "EC913DA4", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1889 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1928 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "8140851B", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "3435E41E", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1929 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2017 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "9844AC67", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "3B000CB3", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2018 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2114 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "DAACC416", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "334E1FE9", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2115 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2173 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "B033EA0C", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "14837B46", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2174 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2299 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "C96CDCCC", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "AA123312", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2300 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2341 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "19482BE8", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "63A730D4", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2342 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2461 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "34418988", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "09319443", + "target": { + "@type": "TextSelector", + "resource": "3635", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2462 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2877 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "921B3D5E", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "A096BE75", + "set": "Translation" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/metadata.json b/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/metadata.json new file mode 100644 index 0000000..54d62eb --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/data/bo/IE60BBDE8/metadata.json @@ -0,0 +1,48 @@ +{ + "id": "IE60BBDE9", + "title": { + "BO": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།", + "EN": "Vajra Cutter Root Book" + }, + "author": null, + "imported": "2025-01-03T16:12:21.284641", + "source": null, + "toolkit_version": "0.0.1", + "parser": "GoogleDocTranslationParser", + "initial_creation_type": "google_docx", + "language": "bo", + "source_metadata": { + "title_short": { + "BO": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།", + "EN": "Vajra Cutter Root Book" + }, + "title_long_clean": { + "BO": "འཕགས་པ་ཤེས་རབ་ཀྱི་ཕ་རོལ་ཏུ་ཕྱིན་པ་རྡོ་རྗེ་གཅོད་པ་ཞེས་བྱ་བ།" + }, + "title_alt_1": { + "BO": "འཕགས་པ་ཤེས་རབ་ཀྱི་ཕ་རོལད་ཏུ་ཕྱིནད་པ་རྡོ་རྗེ་གཅོད་པ་ཞེས་བྱ་བ་ཐེག་པ་ཆེན་པོའི་མདོ།" + }, + "title_alt_2": { + "BO": "རྡོ་རྗེ་སུམ་བརྒྱ་པའམ་རྡོ་རྗེ་གཅོད་པ།" + }, + "is_version_of": { + "BO": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།" + } + }, + "bases": [ + { + "3635": { + "source_metadata": { + "total_segments": 29 + }, + "base_file": "3635.txt" + } + } + ], + "copyright": { + "status": "Unknown", + "notice": "", + "info_url": null + }, + "licence": "Unknown" +} \ No newline at end of file diff --git a/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/base/D93E.txt b/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/base/D93E.txt new file mode 100644 index 0000000..29af1e04 --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/base/D93E.txt @@ -0,0 +1,29 @@ +In Sanskrit: Āryavajracchedikā-prajñāpāramitā-nāma-mahāyāna-sūtra +In Tibetan: The Noble Mahāyāna Sūtra "The Perfection of Wisdom that Cuts Like a Diamond" +Homage to all Buddhas and Bodhisattvas. +Thus have I heard at one time: +The Blessed One was dwelling in Śrāvastī, in the Jeta Grove, in Anāthapiṇḍada's park, together with a great assembly of 1,250 monks and a great number of bodhisattva mahāsattvas. +Then, in the morning, the Blessed One dressed, put on his outer robe, took his alms bowl, and went into the great city of Śrāvastī for alms. +After the Blessed One had gone for alms in the great city of Śrāvastī, partaken of the meal, and completed the act of eating, +He put away his alms bowl and outer robe, washed his feet, arranged his seat, sat down cross-legged, straightened his body, and placed his attention in front of himself. +Then many monks approached the Blessed One, +And having approached, prostrated with their heads at the Blessed One's feet, circumambulated him three times, and sat to one side. +At that time, the venerable Subhūti was also seated in that very assembly. +Then the venerable Subhūti rose from his seat, arranged his upper robe over one shoulder, knelt on his right knee, placed his palms together, and bowed toward the Blessed One. +He addressed the Blessed One thus: +"O Blessed One, the Tathāgata, the Arhat, the Perfectly Enlightened Buddha has bestowed benefit upon the bodhisattva mahāsattvas with the highest benefit, and the Tathāgata has entrusted the bodhisattva mahāsattvas with the highest entrustment. O Blessed One, this is wondrous! +O Sugata, this is wondrous! +Blessed One, how should one who has correctly entered the bodhisattva vehicle abide? +How should one practice? +How should one control the mind?" +Thus he spoke, and +The Blessed One replied to the venerable Subhūti: +"Excellent, excellent, Subhūti! +Subhūti, it is just as you say. +The Tathāgata has indeed bestowed benefit upon the bodhisattva mahāsattvas with the highest benefit. +The Tathāgata has indeed entrusted the bodhisattva mahāsattvas with the highest entrustment. +Therefore, Subhūti, listen well and bear in mind, +I shall explain to you how one who has correctly entered the bodhisattva vehicle should abide, how one should practice, and how one should control the mind." +"Yes, Blessed One," replied the venerable Subhūti, and listened accordingly. +The Blessed One said this to him: +"Here, Subhūti, one who has correctly entered the bodhisattva vehicle should think thus: 'However many beings there are in the universe of beings, whether born from an egg, born from a womb, born from heat and moisture, or born miraculously; whether with form or without form; whether with perception, without perception, or with neither perception nor non-perception; whatever realm of beings is conceived, I shall lead them all to nirvana, into the realm of nirvana without remainder.' \ No newline at end of file diff --git a/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/layers/D93E/English_Segment-0216.json b/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/layers/D93E/English_Segment-0216.json new file mode 100644 index 0000000..57e2c9d --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/layers/D93E/English_Segment-0216.json @@ -0,0 +1,1200 @@ +{ + "@type": "AnnotationStore", + "@id": "I62E00D79", + "resources": [ + { + "@type": "TextResource", + "@id": "D93E", + "@include": "../../base/D93E.txt" + } + ], + "annotationsets": [ + { + "@type": "AnnotationDataSet", + "@id": "Translation", + "keys": [ + { + "@type": "DataKey", + "@id": "root_idx_mapping" + }, + { + "@type": "DataKey", + "@id": "Translation_Segment" + } + ], + "data": [ + { + "@type": "AnnotationData", + "@id": "68D011AA", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "1" + } + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "key": "Translation_Segment", + "value": { + "@type": "String", + "value": "English_Segment" + } + }, + { + "@type": "AnnotationData", + "@id": "A37D737E", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "2" + } + }, + { + "@type": "AnnotationData", + "@id": "6872AAD7", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "3" + } + }, + { + "@type": "AnnotationData", + "@id": "80F540CF", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "4" + } + }, + { + "@type": "AnnotationData", + "@id": "67326666", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "5" + } + }, + { + "@type": "AnnotationData", + "@id": "0384CEB1", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "6" + } + }, + { + "@type": "AnnotationData", + "@id": "78D4014D", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "7" + } + }, + { + "@type": "AnnotationData", + "@id": "F474C959", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "8" + } + }, + { + "@type": "AnnotationData", + "@id": "13517D66", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "9" + } + }, + { + "@type": "AnnotationData", + "@id": "8FAF3875", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "10" + } + }, + { + "@type": "AnnotationData", + "@id": "568595EB", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "11" + } + }, + { + "@type": "AnnotationData", + "@id": "F906E890", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "12" + } + }, + { + "@type": "AnnotationData", + "@id": "0C6035D3", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "13" + } + }, + { + "@type": "AnnotationData", + "@id": "C414C1AF", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "14" + } + }, + { + "@type": "AnnotationData", + "@id": "48F845DE", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "15" + } + }, + { + "@type": "AnnotationData", + "@id": "74C80AC1", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "16" + } + }, + { + "@type": "AnnotationData", + "@id": "124E21F8", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "17" + } + }, + { + "@type": "AnnotationData", + "@id": "0A7CDDB2", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "18" + } + }, + { + "@type": "AnnotationData", + "@id": "74BE9A7C", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "19" + } + }, + { + "@type": "AnnotationData", + "@id": "2A893A47", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "20" + } + }, + { + "@type": "AnnotationData", + "@id": "3C66436C", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "21" + } + }, + { + "@type": "AnnotationData", + "@id": "BBF0C44C", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "22" + } + }, + { + "@type": "AnnotationData", + "@id": "43A99151", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "23" + } + }, + { + "@type": "AnnotationData", + "@id": "13ECC384", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "24" + } + }, + { + "@type": "AnnotationData", + "@id": "71FF9761", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "25" + } + }, + { + "@type": "AnnotationData", + "@id": "3A6F47A2", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "26" + } + }, + { + "@type": "AnnotationData", + "@id": "B76A2C78", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "27" + } + }, + { + "@type": "AnnotationData", + "@id": "37C8BBCF", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "28" + } + }, + { + "@type": "AnnotationData", + "@id": "28488499", + "key": "root_idx_mapping", + "value": { + "@type": "String", + "value": "29" + } + } + ] + } + ], + "annotations": [ + { + "@type": "Annotation", + "@id": "45C7A4A3", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 0 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 65 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "68D011AA", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "D41632E8", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 66 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 154 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "A37D737E", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "C9B95C72", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 155 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 194 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "6872AAD7", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "BC407AC8", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 195 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 225 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "80F540CF", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "DAB266BD", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 226 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 404 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "67326666", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "9AA93B6F", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 405 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 545 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "0384CEB1", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "19774460", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 546 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 671 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "78D4014D", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "D569EE67", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 672 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 841 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "F474C959", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "C45EECBA", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 842 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 885 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "13517D66", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "3E4AE376", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 886 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1017 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "8FAF3875", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "03C6B5EA", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1018 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1092 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "568595EB", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "6B6D4EEE", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1093 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1268 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "F906E890", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "7A704303", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1269 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1303 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "0C6035D3", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "E7098438", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1304 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1581 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "C414C1AF", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "A2CC1646", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1582 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1609 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "48F845DE", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "264324EA", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1610 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1694 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "74C80AC1", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "F86936AB", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1695 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1719 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "124E21F8", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "101C360F", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1720 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1753 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "0A7CDDB2", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "4FA346A4", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1754 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1772 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "74BE9A7C", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "91E99B11", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1773 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1822 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "2A893A47", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "864F8344", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1823 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1854 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "3C66436C", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "F1212A1A", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1855 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1886 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "BBF0C44C", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "B366523C", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1887 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 1987 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "43A99151", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "B5919304", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 1988 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2080 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "13ECC384", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "DDBDC610", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2081 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2130 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "71FF9761", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "4ACE42A4", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2131 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2288 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "3A6F47A2", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "FEF4B4A4", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2289 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2365 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "B76A2C78", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "E44D8463", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2366 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2399 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "37C8BBCF", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + }, + { + "@type": "Annotation", + "@id": "AB475A0D", + "target": { + "@type": "TextSelector", + "resource": "D93E", + "offset": { + "@type": "Offset", + "begin": { + "@type": "BeginAlignedCursor", + "value": 2400 + }, + "end": { + "@type": "BeginAlignedCursor", + "value": 2887 + } + } + }, + "data": [ + { + "@type": "AnnotationData", + "@id": "28488499", + "set": "Translation" + }, + { + "@type": "AnnotationData", + "@id": "147F49A9", + "set": "Translation" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/metadata.json b/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/metadata.json new file mode 100644 index 0000000..23e2ff1 --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/data/en/I62E00D78/metadata.json @@ -0,0 +1,54 @@ +{ + "id": "I62E00D79", + "title": { + "BO": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།", + "EN": "Vajra Cutter Root Book" + }, + "author": null, + "imported": "2025-01-03T16:12:32.152119", + "source": null, + "toolkit_version": "0.0.1", + "parser": "GoogleDocTranslationParser", + "initial_creation_type": "google_docx", + "language": "en", + "source_metadata": { + "title_short": { + "BO": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།", + "EN": "Vajra Cutter Root Book" + }, + "title_long_clean": { + "BO": "འཕགས་པ་ཤེས་རབ་ཀྱི་ཕ་རོལ་ཏུ་ཕྱིན་པ་རྡོ་རྗེ་གཅོད་པ་ཞེས་བྱ་བ།" + }, + "title_alt_1": { + "BO": "འཕགས་པ་ཤེས་རབ་ཀྱི་ཕ་རོལད་ཏུ་ཕྱིནད་པ་རྡོ་རྗེ་གཅོད་པ་ཞེས་བྱ་བ་ཐེག་པ་ཆེན་པོའི་མདོ།" + }, + "title_alt_2": { + "BO": "རྡོ་རྗེ་སུམ་བརྒྱ་པའམ་རྡོ་རྗེ་གཅོད་པ།" + }, + "is_version_of": { + "BO": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།" + }, + "translation_alignments": [ + { + "source": "IE60BBDE9/layers/3635/Tibetan_Segment-039B.json", + "target": "I62E00D79/layers/D93E/English_Segment-0216.json" + } + ] + }, + "bases": [ + { + "D93E": { + "source_metadata": { + "total_segments": 29 + }, + "base_file": "D93E.txt" + } + } + ], + "copyright": { + "status": "Unknown", + "notice": "", + "info_url": null + }, + "licence": "Unknown" +} \ No newline at end of file diff --git a/tests/alignment/serializers/translation/normal_alignment/data/expected_output.json b/tests/alignment/serializers/translation/normal_alignment/data/expected_output.json new file mode 100644 index 0000000..dfd53b4 --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/data/expected_output.json @@ -0,0 +1,134 @@ +{ + "source": { + "categories": [ + { + "name": "The Buddha's Teachings", + "enDesc": "", + "enShortDesc": "" + }, + { + "name": "Vajra Cutter", + "enDesc": "", + "enShortDesc": "" + }, + { + "name": "Commentaries", + "enDesc": "", + "enShortDesc": "" + }, + { + "name": "Vajra Cutter", + "enDesc": "", + "enShortDesc": "" + } + ], + "books": [ + { + "title": "Vajra Cutter Root Book", + "language": "en", + "versionSource": "", + "direction": "ltr", + "completestatus": "done", + "content": [ + [ + "In Sanskrit: Āryavajracchedikā-prajñāpāramitā-nāma-mahāyāna-sūtra", + "In Tibetan: The Noble Mahāyāna Sūtra \"The Perfection of Wisdom that Cuts Like a Diamond\"", + "Homage to all Buddhas and Bodhisattvas.", + "Thus have I heard at one time:", + "The Blessed One was dwelling in Śrāvastī, in the Jeta Grove, in Anāthapiṇḍada's park, together with a great assembly of 1,250 monks and a great number of bodhisattva mahāsattvas.", + "Then, in the morning, the Blessed One dressed, put on his outer robe, took his alms bowl, and went into the great city of Śrāvastī for alms.", + "After the Blessed One had gone for alms in the great city of Śrāvastī, partaken of the meal, and completed the act of eating,", + "He put away his alms bowl and outer robe, washed his feet, arranged his seat, sat down cross-legged, straightened his body, and placed his attention in front of himself.", + "Then many monks approached the Blessed One,", + "And having approached, prostrated with their heads at the Blessed One's feet, circumambulated him three times, and sat to one side.", + "At that time, the venerable Subhūti was also seated in that very assembly.", + "Then the venerable Subhūti rose from his seat, arranged his upper robe over one shoulder, knelt on his right knee, placed his palms together, and bowed toward the Blessed One.", + "He addressed the Blessed One thus:", + "\"O Blessed One, the Tathāgata, the Arhat, the Perfectly Enlightened Buddha has bestowed benefit upon the bodhisattva mahāsattvas with the highest benefit, and the Tathāgata has entrusted the bodhisattva mahāsattvas with the highest entrustment. O Blessed One, this is wondrous!", + "O Sugata, this is wondrous!", + "Blessed One, how should one who has correctly entered the bodhisattva vehicle abide?", + "How should one practice?", + "How should one control the mind?\"", + "Thus he spoke, and", + "The Blessed One replied to the venerable Subhūti:", + "\"Excellent, excellent, Subhūti!", + "Subhūti, it is just as you say.", + "The Tathāgata has indeed bestowed benefit upon the bodhisattva mahāsattvas with the highest benefit.", + "The Tathāgata has indeed entrusted the bodhisattva mahāsattvas with the highest entrustment.", + "Therefore, Subhūti, listen well and bear in mind,", + "I shall explain to you how one who has correctly entered the bodhisattva vehicle should abide, how one should practice, and how one should control the mind.\"", + "\"Yes, Blessed One,\" replied the venerable Subhūti, and listened accordingly.", + "The Blessed One said this to him:", + "\"Here, Subhūti, one who has correctly entered the bodhisattva vehicle should think thus: 'However many beings there are in the universe of beings, whether born from an egg, born from a womb, born from heat and moisture, or born miraculously; whether with form or without form; whether with perception, without perception, or with neither perception nor non-perception; whatever realm of beings is conceived, I shall lead them all to nirvana, into the realm of nirvana without remainder.'" + ] + ] + } + ] + }, + "target": { + "categories": [ + { + "name": "སངས་རྒྱས་ཀྱི་བཀའ།", + "heDesc": "", + "heShortDesc": "" + }, + { + "name": "རྡོ་རྗེ་གཅོད་པ།", + "heDesc": "", + "heShortDesc": "" + }, + { + "name": "འགྲེལ་པ།", + "heDesc": "", + "heShortDesc": "" + }, + { + "name": "རྡོ་རྗེ་གཅོད་པ།", + "heDesc": "", + "heShortDesc": "" + } + ], + "books": [ + { + "title": "རྡོ་རྗེ་གཅོད་པ་རྩ་བ་དེབ།", + "language": "bo", + "versionSource": "", + "direction": "ltr", + "completestatus": "done", + "content": [ + [ + "རྒྱ་གར་སྐད་དུ། ཨརྱཱ་བཛྲ་ཙྪེད་ཀ་པྲཛྙཱ་པ་ར་མི་ཏཱ་ནཱ་མ་མ་ཧཱ་ཡ་ན་སཱུ་ཏྲ།", + "བོད་སྐད་དུ། འཕགས་པ་ཤེས་རབ་ཀྱི་ཕ་རོལ་ཏུ་ཕྱིན་པ་རྡོ་རྗེ་གཅོད་པ་ཞེས་བྱ་བ་ཐེག་པ་ཆེན་པོའི་མདོ།", + "སངས་རྒྱས་དང་བྱང་ཆུབ་སེམས་དཔའ་ཐམས་ཅད་ལ་ཕྱག་འཚལ་ལོ། །", + "འདི་སྐད་བདག་གིས་ཐོས་པ་དུས་གཅིག་ན།", + "བཅོམ་ལྡན་འདས་མཉན་ཡོད་ན་རྒྱལ་བུ་རྒྱལ་བྱེད་ཀྱི་ཚལ་མགོན་མེད་ཟས་སྦྱིན་གྱི་ཀུན་དགའ་ར་བ་ན། དགེ་སློང་སྟོང་ཉིས་བརྒྱ་ལྔ་བཅུའི་དགེ་སློང་གི་དགེ་འདུན་ཆེན་པོ་དང༌། བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རབ་ཏུ་མང་པོ་དག་དང་ཐབས་གཅིག་ཏུ་བཞུགས་སོ། །", + "དེ་ནས་བཅོམ་ལྡན་འདས་སྔ་དྲོའི་དུས་ཀྱི་ཚེ། ཤམ་ཐབས་དང་ཆོས་གོས་སྐུ་ལ་གསོལ་ཏེ། ལྷུང་བཟེད་བསྣམས་ནས་མཉན་ཡོད་ཀྱི་གྲོང་ཁྱེར་ཆེན་པོར་བསོད་སྙོམས་ཀྱི་ཕྱིར་གཤེགས་སོ། །", + "དེ་ནས་བཅོམ་ལྡན་འདས་མཉན་ཡོད་ཀྱི་གྲོང་ཁྱེར་ཆེན་པོར་བསོད་སྙོམས་ཀྱི་ཕྱིར་གཤེགས་ནས་ཞལ་ཟས་གསོལ་ཏེ་ཟས་ཀྱི་བྱ་བ་མཛད་དེ།", + "ཟས་ཕྱི་མའི་བསོད་སྙོམས་སྤངས་ནས་ལྷུང་བཟེད་དང་ཆོས་གོས་བཞག་ནས། ཞབས་བསིལ་ཏེ་གདན་བཤམས་པ་ལ་སྐྱིལ་མོ་ཀྲུང་བཅས་ནས་སྐུ་དྲང་པོར་བསྲང་སྟེ། དྲན་པ་མངོན་དུ་བཞག་ནས་བཞུགས་སོ། །", + "དེ་ནས་དགེ་སློང་མང་པོས་བཅོམ་ལྡན་འདས་ག་ལ་བ་དེར་དོང་སྟེ་ལྷགས་ནས།", + "བཅོམ་ལྡན་འདས་ཀྱི་ཞབས་ལ་མགོ་བོས་ཕྱག་འཚལ་ཏེ་ལན་གསུམ་བསྐོར་བ་བྱས་ནས་ཕྱོགས་གཅིག་ཏུ་འཁོད་དོ། །", + "ཡང་དེའི་ཚེ་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་འཁོར་དེ་ཉིད་དུ་འདུས་པར་གྱུར་ཏེ་འདུག་གོ །", + "དེ་ནས་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་སྟན་ལས་ལངས་ཏེ་བླ་གོས་ཕྲག་པ་གཅིག་ཏུ་གཟར་ནས་པུས་མོ་གཡས་པའི་ལྷ་ང་ས་ལ་བཙུགས་ཏེ། བཅོམ་ལྡན་འདས་ག་ལ་བ་དེར་ལོགས་སུ་ཐལ་མོ་སྦྱར་བ་བཏུད་ནས།", + "བཅོམ་ལྡན་འདས་ལ་འདི་སྐད་ཅེས་གསོལ་ཏོ། །", + "བཅོམ་ལྡན་འདས་དེ་བཞིན་གཤེགས་པ་དགྲ་བཅོམ་པ་ཡང་དག་པར་རྫོགས་པའི་སངས་རྒྱས་ཀྱིས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཕན་གདགས་པའི་དམ་པ་ཇི་སྙེད་པས་ཕན་གདགས་པ་དང༌། དེ་བཞིན་གཤེགས་པས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཡོངས་སུ་གཏད་པའི་དམ་པ་ཇི་སྙེད་པས་ཡོངས་སུ་གཏད་པ་ནི། བཅོམ་ལྡན་འདས་ངོ་མཚར་ལགས་སོ། །", + "བདེ་བར་གཤེགས་པ་ངོ་མཚར་ལགས་སོ། །", + "བཅོམ་ལྡན་འདས་བྱང་ཆུབ་སེམས་དཔའི་ཐེག་པ་ལ་ཡང་དག་པར་ཞུགས་པས་ཇི་ལྟར་གནས་པར་བགྱི།", + "ཇི་ལྟར་བསྒྲུབ་པར་བགྱི།", + "ཇི་ལྟར་སེམས་རབ་ཏུ་གཟུང་བར་བགྱི།", + "དེ་སྐད་ཅེས་གསོལ་པ་དང༌།", + "བཅོམ་ལྡན་འདས་ཀྱིས་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་ལ་འདི་སྐད་ཅེས་བཀའ་སྩལ་ཏོ། །", + "རབ་འབྱོར་ལེགས་སོ་ལེགས་སོ། །", + "རབ་འབྱོར་དེ་དེ་བཞིན་ནོ། །དེ་དེ་བཞིན་ཏེ།", + "དེ་བཞིན་གཤེགས་པས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཕན་གདགས་པའི་དམ་པས་ཕན་གདགས་སོ། །", + "དེ་བཞིན་གཤེགས་པས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཡོངས་སུ་གཏད་པའི་དམ་པས་ཡོངས་སུ་གཏད་དོ། །", + "རབ་འབྱོར་དེའི་ཕྱིར་ཉོན་ལ་ལེགས་པར་རབ་ཏུ་ཡིད་ལ་ཟུངས་ཤིག་དང༌།", + "བྱང་ཆུབ་སེམས་དཔའི་ཐེག་པ་ལ་ཡང་དག་པར་བཞུགས་པས་ཇི་ལྟར་གནས་པར་བྱ་བ་དང༌། བ་དང༌། ཇི་ལྟར་སེམས་རབ་ཏུ་གཟུང་བར་བྱ་བ་ངས་ཁྱོད་ལ་བཤད་དོ། །", + "བཅོམ་ལྡན་འདས་དེ་དེ་བཞིན་ནོ། །ཞེས་གསོལ་ནས།", + "ཚེ་དང་ལྡན་པ་རབ་འབྱོར་བཅོམ་ལྡན་འདས་ཀྱི་ལྟར་མཉན་པ་དང༌། བཅོམ་ལྡན་འདས་ཀྱིས་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་ལ་འདི་སྐད་ཅེས་བཀའ་སྩལ་ཏོ། །", + "རབ་འབྱོར་འདི་ལ་བྱང་ཆུབ་སེམས་དཔའི་ཐེག་པ་ལ་ཡང་དག་པར་ཞུགས་པས། འདི་སྙམ་དུ་བདག་གིས་སེམས་ཅན་ཇི་ཙམ་སེམས་ཅན་དུ་བསྡུ་བས་བསྡུས་པ། སྒོ་ང་ལས་སྐྱེས་པའམ། མངལ་ལས་སྐྱེས་པའམ། དྲོད་གཤེར་ལས་སྐྱེས་པའམ། རྫུས་ཏེ་སྐྱེས་པའམ། གཟུགས་ཅན་ནམ། གཟུགས་ཅན་མ་ཡིན་པའམ། དུ་ཤེས་ཅན་ནམ། འདུ་ཤེས་མེད་འདུ་ཤེས་མེད་མིན་ནམ། སེམས་ཅན་གྱི་ཁམས་ཇི་ཙམ་སེམས་ཅན་དུ་གདགས་པའི་བརྟགས་པ་དེ་དག་ཐམས་ཅད་ཕུང་པོ་ལྷག་མ་མེད་པའི་མྱ་ངན་ལས་འདས་པའི་དབྱིངས་སུ་ཡོངས་སུ་མྱ་ངན་ལས་འདའོ། །" + ] + ] + } + ] + } +} \ No newline at end of file diff --git a/tests/alignment/serializers/translation/normal_alignment/test_normal_translation_serializer.py b/tests/alignment/serializers/translation/normal_alignment/test_normal_translation_serializer.py new file mode 100644 index 0000000..cc54564 --- /dev/null +++ b/tests/alignment/serializers/translation/normal_alignment/test_normal_translation_serializer.py @@ -0,0 +1,50 @@ +import tempfile +from pathlib import Path +from unittest import TestCase, mock + +from openpecha.alignment.serializers.translation import TextTranslationSerializer +from openpecha.utils import read_json + +DATA_DIR = Path(__file__).parent / "data" + + +class TestTextTranslationSerializer(TestCase): + def setUp(self): + # Create the patcher and set return_value + self.patcher = mock.patch( + "openpecha.alignment.serializers.translation.CategoryExtractor.get_category", + return_value={ + "bo": [ + {"name": "སངས་རྒྱས་ཀྱི་བཀའ།", "heDesc": "", "heShortDesc": ""}, + {"name": "རྡོ་རྗེ་གཅོད་པ།", "heDesc": "", "heShortDesc": ""}, + {"name": "འགྲེལ་པ།", "heDesc": "", "heShortDesc": ""}, + {"name": "རྡོ་རྗེ་གཅོད་པ།", "heDesc": "", "heShortDesc": ""}, + ], + "en": [ + {"name": "The Buddha's Teachings", "enDesc": "", "enShortDesc": ""}, + {"name": "Vajra Cutter", "enDesc": "", "enShortDesc": ""}, + {"name": "Commentaries", "enDesc": "", "enShortDesc": ""}, + {"name": "Vajra Cutter", "enDesc": "", "enShortDesc": ""}, + ], + }, + ) + # Start the patch + self.mock_get_category = self.patcher.start() + + def test_translation_serializer(self): + root_opf = DATA_DIR / "bo/IE60BBDE8" + translation_opf = DATA_DIR / "en/I62E00D78" + with tempfile.TemporaryDirectory() as tmpdirname: + output_dir = Path(tmpdirname) + + serializer = TextTranslationSerializer() + json_output = serializer.serialize( + root_opf, translation_opf, output_dir, False + ) + + expected_json_path = DATA_DIR / "expected_output.json" + assert read_json(json_output) == read_json(expected_json_path) + + def tearDown(self): + # Stop the patch + self.patcher.stop() diff --git a/tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/base/4665.txt b/tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/base/4665.txt new file mode 100644 index 0000000..7c067ee --- /dev/null +++ b/tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/base/4665.txt @@ -0,0 +1,29 @@ +རྒྱ་གར་སྐད་དུ། ཨརྱཱ་བཛྲ་ཙྪེད་ཀ་པྲཛྙཱ་པ་ར་མི་ཏཱ་ནཱ་མ་མ་ཧཱ་ཡ་ན་སཱུ་ཏྲ། +བོད་སྐད་དུ། འཕགས་པ་ཤེས་རབ་ཀྱི་ཕ་རོལ་ཏུ་ཕྱིན་པ་རྡོ་རྗེ་གཅོད་པ་ཞེས་བྱ་བ་ཐེག་པ་ཆེན་པོའི་མདོ། +སངས་རྒྱས་དང་བྱང་ཆུབ་སེམས་དཔའ་ཐམས་ཅད་ལ་ཕྱག་འཚལ་ལོ། ། +འདི་སྐད་བདག་གིས་ཐོས་པ་དུས་གཅིག་ན། +བཅོམ་ལྡན་འདས་མཉན་ཡོད་ན་རྒྱལ་བུ་རྒྱལ་བྱེད་ཀྱི་ཚལ་མགོན་མེད་ཟས་སྦྱིན་གྱི་ཀུན་དགའ་ར་བ་ན། དགེ་སློང་སྟོང་ཉིས་བརྒྱ་ལྔ་བཅུའི་དགེ་སློང་གི་དགེ་འདུན་ཆེན་པོ་དང༌། བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རབ་ཏུ་མང་པོ་དག་དང་ཐབས་གཅིག་ཏུ་བཞུགས་སོ། ། +དེ་ནས་བཅོམ་ལྡན་འདས་སྔ་དྲོའི་དུས་ཀྱི་ཚེ། ཤམ་ཐབས་དང་ཆོས་གོས་སྐུ་ལ་གསོལ་ཏེ། ལྷུང་བཟེད་བསྣམས་ནས་མཉན་ཡོད་ཀྱི་གྲོང་ཁྱེར་ཆེན་པོར་བསོད་སྙོམས་ཀྱི་ཕྱིར་གཤེགས་སོ། ། +དེ་ནས་བཅོམ་ལྡན་འདས་མཉན་ཡོད་ཀྱི་གྲོང་ཁྱེར་ཆེན་པོར་བསོད་སྙོམས་ཀྱི་ཕྱིར་གཤེགས་ནས་ཞལ་ཟས་གསོལ་ཏེ་ཟས་ཀྱི་བྱ་བ་མཛད་དེ། +ཟས་ཕྱི་མའི་བསོད་སྙོམས་སྤངས་ནས་ལྷུང་བཟེད་དང་ཆོས་གོས་བཞག་ནས། ཞབས་བསིལ་ཏེ་གདན་བཤམས་པ་ལ་སྐྱིལ་མོ་ཀྲུང་བཅས་ནས་སྐུ་དྲང་པོར་བསྲང་སྟེ། དྲན་པ་མངོན་དུ་བཞག་ནས་བཞུགས་སོ། ། +དེ་ནས་དགེ་སློང་མང་པོས་བཅོམ་ལྡན་འདས་ག་ལ་བ་དེར་དོང་སྟེ་ལྷགས་ནས། +བཅོམ་ལྡན་འདས་ཀྱི་ཞབས་ལ་མགོ་བོས་ཕྱག་འཚལ་ཏེ་ལན་གསུམ་བསྐོར་བ་བྱས་ནས་ཕྱོགས་གཅིག་ཏུ་འཁོད་དོ། ། +ཡང་དེའི་ཚེ་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་འཁོར་དེ་ཉིད་དུ་འདུས་པར་གྱུར་ཏེ་འདུག་གོ ། +དེ་ནས་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་སྟན་ལས་ལངས་ཏེ་བླ་གོས་ཕྲག་པ་གཅིག་ཏུ་གཟར་ནས་པུས་མོ་གཡས་པའི་ལྷ་ང་ས་ལ་བཙུགས་ཏེ། བཅོམ་ལྡན་འདས་ག་ལ་བ་དེར་ལོགས་སུ་ཐལ་མོ་སྦྱར་བ་བཏུད་ནས། +བཅོམ་ལྡན་འདས་ལ་འདི་སྐད་ཅེས་གསོལ་ཏོ། ། +བཅོམ་ལྡན་འདས་དེ་བཞིན་གཤེགས་པ་དགྲ་བཅོམ་པ་ཡང་དག་པར་རྫོགས་པའི་སངས་རྒྱས་ཀྱིས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཕན་གདགས་པའི་དམ་པ་ཇི་སྙེད་པས་ཕན་གདགས་པ་དང༌། དེ་བཞིན་གཤེགས་པས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཡོངས་སུ་གཏད་པའི་དམ་པ་ཇི་སྙེད་པས་ཡོངས་སུ་གཏད་པ་ནི། བཅོམ་ལྡན་འདས་ངོ་མཚར་ལགས་སོ། ། +བདེ་བར་གཤེགས་པ་ངོ་མཚར་ལགས་སོ། ། +བཅོམ་ལྡན་འདས་བྱང་ཆུབ་སེམས་དཔའི་ཐེག་པ་ལ་ཡང་དག་པར་ཞུགས་པས་ཇི་ལྟར་གནས་པར་བགྱི། +ཇི་ལྟར་བསྒྲུབ་པར་བགྱི། +ཇི་ལྟར་སེམས་རབ་ཏུ་གཟུང་བར་བགྱི། +དེ་སྐད་ཅེས་གསོལ་པ་དང༌། +བཅོམ་ལྡན་འདས་ཀྱིས་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་ལ་འདི་སྐད་ཅེས་བཀའ་སྩལ་ཏོ། ། +རབ་འབྱོར་ལེགས་སོ་ལེགས་སོ། ། +རབ་འབྱོར་དེ་དེ་བཞིན་ནོ། །དེ་དེ་བཞིན་ཏེ། +དེ་བཞིན་གཤེགས་པས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཕན་གདགས་པའི་དམ་པས་ཕན་གདགས་སོ། ། +དེ་བཞིན་གཤེགས་པས་བྱང་ཆུབ་སེམས་དཔའ་སེམས་དཔའ་ཆེན་པོ་རྣམས་ལ་ཡོངས་སུ་གཏད་པའི་དམ་པས་ཡོངས་སུ་གཏད་དོ། ། +རབ་འབྱོར་དེའི་ཕྱིར་ཉོན་ལ་ལེགས་པར་རབ་ཏུ་ཡིད་ལ་ཟུངས་ཤིག་དང༌། +བྱང་ཆུབ་སེམས་དཔའི་ཐེག་པ་ལ་ཡང་དག་པར་བཞུགས་པས་ཇི་ལྟར་གནས་པར་བྱ་བ་དང༌། བ་དང༌། ཇི་ལྟར་སེམས་རབ་ཏུ་གཟུང་བར་བྱ་བ་ངས་ཁྱོད་ལ་བཤད་དོ། ། +བཅོམ་ལྡན་འདས་དེ་དེ་བཞིན་ནོ། །ཞེས་གསོལ་ནས། +ཚེ་དང་ལྡན་པ་རབ་འབྱོར་བཅོམ་ལྡན་འདས་ཀྱི་ལྟར་མཉན་པ་དང༌། བཅོམ་ལྡན་འདས་ཀྱིས་ཚེ་དང་ལྡན་པ་རབ་འབྱོར་ལ་འདི་སྐད་ཅེས་བཀའ་སྩལ་ཏོ། ། +རབ་འབྱོར་འདི་ལ་བྱང་ཆུབ་སེམས་དཔའི་ཐེག་པ་ལ་ཡང་དག་པར་ཞུགས་པས། འདི་སྙམ་དུ་བདག་གིས་སེམས་ཅན་ཇི་ཙམ་སེམས་ཅན་དུ་བསྡུ་བས་བསྡུས་པ། སྒོ་ང་ལས་སྐྱེས་པའམ། མངལ་ལས་སྐྱེས་པའམ། དྲོད་གཤེར་ལས་སྐྱེས་པའམ། རྫུས་ཏེ་སྐྱེས་པའམ། གཟུགས་ཅན་ནམ། གཟུགས་ཅན་མ་ཡིན་པའམ། དུ་ཤེས་ཅན་ནམ། འདུ་ཤེས་མེད་འདུ་ཤེས་མེད་མིན་ནམ། སེམས་ཅན་གྱི་ཁམས་ཇི་ཙམ་སེམས་ཅན་དུ་གདགས་པའི་བརྟགས་པ་དེ་དག་ཐམས་ཅད་ཕུང་པོ་ལྷག་མ་མེད་པའི་མྱ་ངན་ལས་འདས་པའི་དབྱིངས་སུ་ཡོངས་སུ་མྱ་ངན་ལས་འདའོ། ། \ No newline at end of file diff --git a/tests/alignment/serializers/translation/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-4D29.json b/tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-4D29.json similarity index 100% rename from tests/alignment/serializers/translation/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-4D29.json rename to tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-4D29.json diff --git a/tests/alignment/serializers/translation/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-E855.json b/tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-E855.json similarity index 100% rename from tests/alignment/serializers/translation/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-E855.json rename to tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/layers/4665/Tibetan_Segment-E855.json diff --git a/tests/alignment/serializers/translation/data/bo/IFA46BBC2/metadata.json b/tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/metadata.json similarity index 100% rename from tests/alignment/serializers/translation/data/bo/IFA46BBC2/metadata.json rename to tests/alignment/serializers/translation/pecha_display/data/bo/IFA46BBC2/metadata.json diff --git a/tests/alignment/serializers/translation/data/en/I6EA29D09/base/564C.txt b/tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/base/564C.txt similarity index 100% rename from tests/alignment/serializers/translation/data/en/I6EA29D09/base/564C.txt rename to tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/base/564C.txt diff --git a/tests/alignment/serializers/translation/data/en/I6EA29D09/layers/564C/English_Segment-9F9B.json b/tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/layers/564C/English_Segment-9F9B.json similarity index 100% rename from tests/alignment/serializers/translation/data/en/I6EA29D09/layers/564C/English_Segment-9F9B.json rename to tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/layers/564C/English_Segment-9F9B.json diff --git a/tests/alignment/serializers/translation/data/en/I6EA29D09/layers/564C/Pecha_Display_Alignment_Segment-891D.json b/tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/layers/564C/Pecha_Display_Alignment_Segment-891D.json similarity index 100% rename from tests/alignment/serializers/translation/data/en/I6EA29D09/layers/564C/Pecha_Display_Alignment_Segment-891D.json rename to tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/layers/564C/Pecha_Display_Alignment_Segment-891D.json diff --git a/tests/alignment/serializers/translation/data/en/I6EA29D09/metadata.json b/tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/metadata.json similarity index 100% rename from tests/alignment/serializers/translation/data/en/I6EA29D09/metadata.json rename to tests/alignment/serializers/translation/pecha_display/data/en/I6EA29D09/metadata.json diff --git a/tests/alignment/serializers/translation/data/expected_output.json b/tests/alignment/serializers/translation/pecha_display/data/expected_output.json similarity index 100% rename from tests/alignment/serializers/translation/data/expected_output.json rename to tests/alignment/serializers/translation/pecha_display/data/expected_output.json diff --git a/tests/alignment/serializers/translation/test_translation_serializer.py b/tests/alignment/serializers/translation/pecha_display/test_translation_serializer.py similarity index 84% rename from tests/alignment/serializers/translation/test_translation_serializer.py rename to tests/alignment/serializers/translation/pecha_display/test_translation_serializer.py index a3ed21e..77e616d 100644 --- a/tests/alignment/serializers/translation/test_translation_serializer.py +++ b/tests/alignment/serializers/translation/pecha_display/test_translation_serializer.py @@ -2,19 +2,17 @@ from pathlib import Path from unittest import TestCase, mock -from openpecha.alignment.serializers.simple_text_translation import ( - SimpleTextTranslationSerializer, -) +from openpecha.alignment.serializers.translation import TextTranslationSerializer from openpecha.utils import read_json DATA_DIR = Path(__file__).parent / "data" -class TestSimpleTextTranslationSerializer(TestCase): +class TestTextTranslationSerializer(TestCase): def setUp(self): # Create the patcher and set return_value self.patcher = mock.patch( - "openpecha.alignment.serializers.simple_text_translation.CategoryExtractor.get_category", + "openpecha.alignment.serializers.translation.CategoryExtractor.get_category", return_value={ "bo": [ {"name": "སངས་རྒྱས་ཀྱི་བཀའ།", "heDesc": "", "heShortDesc": ""}, @@ -39,7 +37,7 @@ def test_translation_serializer(self): with tempfile.TemporaryDirectory() as tmpdirname: output_dir = Path(tmpdirname) - serializer = SimpleTextTranslationSerializer() + serializer = TextTranslationSerializer() json_output = serializer.serialize(root_opf, translation_opf, output_dir) expected_json_path = DATA_DIR / "expected_output.json"