Skip to content

Commit

Permalink
fix(hfml-serializer): subtext serializer bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kaldan007 committed Aug 17, 2021
1 parent 5296ebd commit 01d31c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions openpecha/serializers/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ def apply_index(self):
for ann_id, topic in self.index_layer["annotations"].items():
topic_ann = defaultdict(str)
sub_topics = topic["parts"]
for i, sub_topic in enumerate(sub_topics):
if sub_topic:
vol_id = f"v{sub_topic['span']['vol']:03}"
sub_topic["type"] = AnnType.sub_topic
if sub_topic["work_id"] != sub_topics[i - 1]["work_id"]:
self.apply_annotation(vol_id, sub_topic)
for sub_topic_uuid, sub_topic in sub_topics.items():
sub_topic_ann = defaultdict(str)
vol_id = f"v{sub_topic['span'][0]['vol']:03}"
sub_topic_ann["type"] = AnnType.sub_topic
sub_topic_ann["work_id"] = sub_topic["work_id"]
sub_topic_ann["span"] = sub_topic['span'][0]
self.apply_annotation(vol_id, sub_topic_ann)
if topic["span"]:
vol_id = f"v{topic['span'][0]['vol']:03}"
topic_ann["type"] = AnnType.topic
Expand Down
4 changes: 2 additions & 2 deletions tests/data/serialize/hfml/opf/P000003.opf/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ annotation_type: index
revision: '00001'
annotations:
12590fb37da14c32ba0785f7f68c6f5e:
parts: []
parts: {}
span:
- vol: 1
start: 0
Expand All @@ -13,7 +13,7 @@ annotations:
end: 218
work_id: D1118
ac26bb9b4a034a0fa959ecc6af68fa0e:
parts: []
parts: {}
span:
- vol: 2
start: 218
Expand Down

0 comments on commit 01d31c2

Please sign in to comment.